Chapter 9. Making Use of the ProcessHandle API
In the previous chapter, we discovered the Java Microbenchmark Harness (JMH). We explored performance tests and how to write them using JMH, the Java library for writing benchmarks for the Java Virtual Machine. We started with an overview of microbenchmarking, then looked at microbenchmarking with Maven, reviewed benchmarking options, and concluded with techniques for avoiding microbenchmarking pitfalls.
In this chapter, we will focus on the updates to the Process
class and the new java.lang.ProcessHandle
API. Prior to Java 9, managing processes in Java was never easy, because Java was rarely used to automate the controlling of other processes. The API was insufficient with some features lacking and some tasks needed to be solved in a system specific manner. For example, in Java 8, giving a process access to its own process identifier (PID) was an unnecessarily difficult task.
In this chapter, the reader will gain all the knowledge that is needed...