I am starting a number of external processes (using the class Process) from a class in Java that is itself called by a job scheduler on a Linux platform.
My problem is that the job scheduler kills everything as soon as the last process has been called by the main class.
So I am looking for something like a ThreadPoolExecutor/CountDownLatch kind of way to manage these processes and make the main class wait for them to finish before exiting.
If I call process.waitFor() inside my loop, they will be started sequentially, which I don't want.
Do I need to put these processes into Threads and use a real ThreadPoolExecutor or is there a prettier/simpler way?