进程p = Runtime.getRuntime()。exec()将异步运行?

时间:2016-02-25 09:00:45

标签: java multithreading process runtime runtime.exec

从这种情况开始:

        for (String certificateSha1:certificateSha1List){
            Process p = Runtime.getRuntime().exec(new String [] {"security", "delete-certificate", "-Z", certificateSha1}, null , new File(this.workDir+"") );      

            Helpers.asynchOutputWrite(new InputStreamReader(p.getInputStream()), standardOutput);
        }

并注意到Helpers.asynchOutputWrite生成了一个新线程,它将参数化流写入该输出文件......这些线程是否会重叠写入文件?或者是for wait的下一次迭代,直到exec()方法完成?

由于

1 个答案:

答案 0 :(得分:3)

除非您致电p.waitFor();,否则您的流程将与其产生的流程(p)并行运行。