Runtime r = Runtime.getRuntime();
Process p = r.exec( "cmd.exe /c " + " start .\\batch.bat ");
try {
p.waitFor();
System.out.println( "Run to here ");
System.out.println( "Run to here 2222222 ");
} catch (InterruptedException e) {
e.printStackTrace();
}
发现batch.bat还在跑, "Run to here "已经打出来了,
JavaDoc里说waitFor()方法会等到该子进程结束。
求教,调用外部shell时怎么同步
------解决方案--------------------
去掉 "start "