另起一个Thread去waitProcess prc=Runtime.getRuntime().exec(cmd);
Thread thread = new Thread (new Runnable(){
public void run() {
try{
prc.waitFor();
}catch(InterruptedException e ) {}
if(prc.exitValue() != 0){
// 在指定的seconds之内子进程没有结束,就强制结束子进程。
prc.destroy();
}
}});
thread.start();
synchronized(this){
try{
this.wait(1000);
}catch(Exception e ) {}
if( thread .isAlive())
thread.interrupt();
}
Thread thread = new Thread (new Runnable(){
public void run() {
try{
prc.waitFor();
}catch(InterruptedException e ) {}
if(prc.exitValue() != 0){
// 在指定的seconds之内子进程没有结束,就强制结束子进程。
prc.destroy();
}
}});
thread.start();
synchronized(this){
try{
this.wait(1000);
}catch(Exception e ) {}
if( thread .isAlive())
thread.interrupt();
}
解决方案 »
- Graphics中drawString()方法的y坐标表示的是字体左上角还是左下角
- java的图形界面编程SWT到底有没有前途啊,在桌面应用中有市场吗?
- struts2情况下如何运行普通的servlet
- o0o0如果有一百万条数据的文本文件如何快速查找一个字符串0o0o
- java求助!!!
- 请大家看看这个程序
- 用java写的需要认证的网站上提交信息
- 如何让批处理文件执行完毕后窗口不关闭,批处理文件直接点击执行
- CallableStatement 应用求教
- 怎麼在網頁裡實現用回車傳遞焦點?用javascript.
- 用Runtime.getRuntime().exec()如何知道启动的应用程序结束?
- 新手提问:怎样开发Java的b/s模式的系统?
这样的话程序的开销就增加了很多