Terminating processes

To terminate a process we can call the destroy() method or the destroyForcibly() method on the ProcessHandle instance. Both of these methods will terminate the process. The destroy() method is expected to terminate the process gracefully executing the process shutdown sequence. In this case the shutdown hooks added to the run time are executed if the actual implementation supports the graceful, normal termination of processes. The destroyForcibly() method will enforce process termination, and in this case the shutdown sequence will not be executed.

If the process managed by the handle is not alive then nothing happens when the code calls any of these methods. If there are any CompletableFuture objects created calling ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.