How to change the priority of a running java process?

后端 未结 3 1561
挽巷
挽巷 2020-12-11 23:40

In a related question we explored using ProcessBuilder to start external processes in low priority using OS-dependant commands. I also discovered that if a parent process is

3条回答
  •  情歌与酒
    2020-12-12 00:10

    Perhaps you are trying to do something the OS does for you.

    In Unix, under load, each process is given a short time slice to do its work. If it uses all its time slice it is assume the process is CPU bound it priority is lowers. If it blocks on IO, it is assumed to be IO bound and its priority is raised (because it didn't use all its time slice)

    All this only matters if there isn't enough CPU. If you keep you CPU load below 100% most of the time, every process will get as much CPU as it needs and the priority doesn't make much difference.

提交回复
热议问题