Listing children

To get the stream of process handles that can be used to control the children, the static method processHandle.children() should be used. This will create a snapshot of the children processes of the process represented by processHandle and create the Stream. Since processes are dynamic there is no guarantee that during the code execution, while our program attends to the handles, that all children processes are still active. Some of them may terminate and our process may spawn new children, perhaps from a different thread. Thus the code should not assume that each of the ProcessHandle elements of the stream represents an active and running process.

The following program starts 10 command prompts in Windows and then counts ...

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.