Let's create a simple shell script, which we will be using in the recipe. This script can be found at chp8/11_managing_sub_process/script.sh:
echo "Running tree command"; tree; sleep 60; echo "Running iostat command"; iostat;
In the preceding script, we are running the commands, tree and iostat, separated by a sleep time of 1 minute. If you want to know about these commands, please refer to the Running shell scripts recipe of this chapter. The sleep command, when executed from within the bash shell, creates a new subprocess each time it is invoked.
We will create, say, 10 instances of ProcessBuilder to run the preceding shell script and launch them simultaneously.