Making Java Processes Play Nice

Looking around, it seems that there is no easy way to stop Java from eating all your system resources when running a particularly heavy-going task.

Thankfully my lovely colleague Ben made me aware of a helpful UNIX command called nice.

By prefixing nice to any command you can ask the scheduler to be a bit more kind, running the process at a slightly lower priority to ensure it doesn’t starve other resources of CPU time:

nice java ExpensiveTask

Notes