java调用外部程序出现死机的问题
java调用外部程序的方法:
String cmd="外部程序的路径"
try {
????????Process?proc = Runtime.getRuntime().exec(cmd)?
??} catch (IOException e) {
???????System.out.println("Error exec!");
??}
finally{
?????????if(proc==null){
??????????? ?proc.destroy();
??????? ?}
? }
在使用这段代码时,一直很正常,后来一运行就死机,查看任务管理器,开了很多的进程,内存一直上升,最后死机,暂不知是什么原因,但在try{}块加上Thread.sleep(50)后,正常了。知道原因的留个言,不甚感激!
?
?