I have a java class that creates a process, called child, using ProcessBuilder. The child process generates a lot of output that I am draining on a separate thread to keep the
You can join on that thread. You would get the instance of the thread and when needed to wait invoke its join method.
Thread th = new Thread(new Runnable() { ... } );
th.start();
//do work
//when need to wait for it to finish
th.join();
//th has now finished
Others will suggest a CountdownLatch, CyclicBarrier or even a Future but I find this to be easiest to implement on a very low level.