java进程优先级,跨平台方式改变java进程优先级
I need to invoke .jar file in separate JVM from another java application, and it very CPU-consuming, so it should run with background priority in order not to affect the rest of the system. Is there any cross-platform method to do this?
解決方案
The simple answer is that there is no portable way to change the priority of a Process in Java. (Threads - yes, Processes - no.)
If your Java application needs to start a new JVM to run the CPU intensive application, then the chances are that it is already not entirely portable. For example, you will typically need to give the pathname of the java command (or equivalent), a -cp argument (or equivalent), system specific JVM options, and so on.
So, assuming that the command to launch the JVM is already non-portable, it should hardly matter if you replace the command with a wrapper script that does OS-specific things to change the priority of the launched process. (For example, for UNIX or Linux you could simply use nice to launch the JVM.)
總結
以上是生活随笔為你收集整理的java进程优先级,跨平台方式改变java进程优先级的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jsonp java后台_jsonp与J
- 下一篇: java 读取 excel poi_ja