Process.waitFor() a thread
问题 While running an external script, I want to read the ErrorStream and OutputStream of this script both simultaneously and separately and then process them further. Therefore, I start a Thread for one of the streams. Unfortunately, the Process doesn't seem to waitFor the Thread to be terminated, but return after the non-threaded stream has no further input. In a nutshell, here is what I am doing: ProcessBuilder pb = new ProcessBuilder(script); final Process p = pb.start(); new Thread(new