How can java thread priority be converted to OS thread priority?

How Java API thread priority (1-10) is converted to operating system level priority, because most operating systems do not have matching thread priority (expressed in numbers)

So remember, if two or more threads with different priorities eventually get the same priority at the OS level, there will be a situation

Please clarify if I have some amendments to my understanding

Solution

In fact, some priorities can be mapped to the same "native" priority This is the list (based on the hotspot code in openjdk 6):

Solaris for

> 1⇒0 > 2⇒32 > 3⇒64 > 4⇒96 > 5 – 10⇒127

It is worth noting that on Solaris, you cannot raise the thread priority below the normal value, but lower it: the priority value of 5 is the same as any higher value

Linux

>1 – 10 ⇒ 4 – - 5 (good value)

It is worth noting that on Linux, different thread priorities in java do map to different priority values at the native level

window

> 1 – 2⇒THREAD_ PRIORITY_ LOWEST> 3 – 4⇒THREAD_ PRIORITY_ BELOW_ NORMAL> 5 – 6⇒THREAD_ PRIORITY_ NORMAL> 7 – 8⇒THREAD_ PRIORITY_ ABOVE_ NORMAL> 9 – 10⇒THREAD_ PRIORITY_ HIGHEST

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>