首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

求教Runtime.exec如何同步

2012-01-06 
求教Runtime.exec怎么同步RuntimerRuntime.getRuntime()Processpr.exec( cmd.exe/c +start.\\batch.

求教Runtime.exec怎么同步
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 "

热点排行