I have a small question about threads.
On Unix systems, we have nice, which can be used to set priorities
processes.
OK, on my system, I call some external processes, however, I would like to
set priority for them.
In unix, I could call other ProcessBuilder and set the nice to
process I want, but in Windows, it is not possible.
If I start a thread with some priority, and use within ProcessBuilder
it, the process will have the same priority as thread?
Or is there some other way to do this?
Cheers
There’s no way to set priority on a process (
Process) level in Java.The process will run side by side with the JVM, so it will not inherit the threads priority. It will be scheduled on it’s own by the operating system.
As stated above, there is no built in cross-platform way of tweaking the priority of a process, but there is a
Thread.setPriority(int)though. So perhaps you could do the work by the external program in a separate thread (instead of starting a new process) and use thesetPrioritymethod on this thread.Related questions / answers: