Search code examples
javalinuxmultithreadingthread-prioritynice

Does "nice" affect the priority of Java threads


On a Unix system, you can run a process at lower CPU "priority" (pedantically, it does not change the thing that is called the priority, but rather influences what share of available CPU time is used, which is "priority" in the general sense) using the nice command:

 nice program

And you could use that to run a JVM process:

 nice java -jar program.jar

The Java program run by that JVM process will start multiple threads.

Does the nice change affect the scheduling of those Java threads? That is, will the Java threads have a lower CPU priority when run as

 nice java -jar program.jar

that when run as

 java -jar program.jar

In general, this will be system dependent, so I am interested in the Linux case.


Solution

  • Actually...Niceness is a property of the application according to POSIX.1. Here is a more detailed post. is nice() used to change the thread priority or the process priority?