A bit of background -XX:ThreadPriorityPolicy .
These were the values as indicated in the source code.
0 : Normal. VM chooses priorities that are appropriate for normal applications. On Solaris NORM_PRIORITY and above are mapped to normal native priority. Java priorities below NORM_PRIORITY map to lower native priority values. On Windows applications are allowed to use higher native priorities. However, with ThreadPriorityPolicy=0, VM will not use the highest possible native priority, THREAD_PRIORITY_TIME_CRITICAL, as it may interfere with system threads. On Linux thread priorities are ignored because the OS does not support static priority in SCHED_OTHER scheduling class which is the only choice for non-root, non-realtime applications. 1 : Aggressive. Java thread priorities map over to the entire range of native thread priorities. Higher Java thread priorities map to higher native thread priorities. This policy should be used with care, as sometimes it can cause performance degradation in the application and/or the entire system. On Linux this policy requires root privilege.
In other words: The default default setting causes thread priorities to be ignored on Linux.
Now, someone has detected an error in the code that has disabled "Is root?" check the values other than 1, but still try to set the priority of the stream for each value other than 0.
If it does not work as root, it will only be possible to lower the priority of the thread. Thus, although not ideal, it was a pretty significant improvement over the inability to control priorities at all.
Starting with Java 9, command-line arguments like this one started checking checked , and this hack stopped working.
By the way, in Java 11 / Linux, I can set the parameter to 1 without being root, and setting thread priorities has an effect. So something has changed during this time, and at least with recent JVMs, and this hack no longer seems necessary.
source share