Making Use of the Process API

In the previous chapter, we learned that the Java Microbenchmark Harness (JMH) is a Java harness library for writing benchmarks for the JVM. We experimented with writing performance tests using Maven along with JMH to help illustrate the procedures of microbenchmarking with the new Java platform. We started with a microbenchmarking overview, then dove deep into microbenchmarking with Maven, reviewed benchmarking options, and concluded with a few techniques for avoiding microbenchmarking pitfalls.

In this chapter, we will focus on the updates to the Process class and the java.lang.ProcessHandle API. In earlier versions of Java, prior to Java 9, managing processes in Java was difficult. 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, we will explore the requisite knowledge needed to write an application that manages other processes utilizing Java's process management API. Specifically, we will cover the following:

  • Introducing processes
  • Working with the ProcessHandle interface
  • Reviewing a sample process controller app

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset