1

是否可以限制 a 的 CPU 使用率Runtime.getRuntime().exec

在标题中的问题之后,我想知道是否存在任何库来限制运行进程时的 CPU 使用率Runtime.getRuntime().exec。在 Java 之外,我可以使用诸如等之类的 shell 命令cpulimit,但我对 Java 替代方案感到好奇。

4

1 回答 1

2

Out of Java I can use shell commands like 'cpulimit' etc, but I am curious about a Java alternative.

You would do it the same way; e.g. by wrapping the command to be "limited" in a shell script / batch file that sets the limits using the relevant commands.

(Java doesn't provide direct support for this kind of thing, so you have no choice but to resort to platform specific "hacks" like this.)

于 2013-06-24T10:39:41.163 回答