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
final StringBuffer outtext = new StringBuffer("");
Thread outputDrainThread = new Thread(new Runnable() {
public void run() {
// ...
}
}).start();
// ...
// ***HERE IS WHERE I NEED TO WAIT FOR THE THREAD TO FINISH ***
outputDrainThread.join();
// ...
return outtext.toString();