Using a thread to capture process output

前端 未结 4 488
深忆病人
深忆病人 2020-12-06 22:11

I am using a thread to capture stream output from a process, and then outputting that stream to the eclipse console. The question I have is when to terminate the thread that

4条回答
  •  北海茫月
    2020-12-06 22:50

    You will need to have two threads. One to handle the I/O and another to wait for process completion (Process.waitFor()) and set a flag telling the I/O thread to quit when it exhausts the data.

提交回复
热议问题