作者starskgb (Metal)
看板java
标题[问题] thread+呼叫外部程式
时间Thu Apr 3 17:08:44 2008
当main里有回圈或等待输入等情况时,叫出来的外部程式会block住,一定要等整只程式
结束或按crl+c外部程式才会开始run,要怎麽让程式跟外部程式都能跑呢??谢谢~~
call外部程式的部分,无论放在main,while,thread里都一样,都会被block住@@
code如下:
class th extends Thread {
public void run()
{
try {
Runtime t = Runtime.getRuntime();
Process pr=t.exec(某执行档);
} catch (IOException e) { }
}
}
class test {
public static void main(String args[]) throws Exception
{
th x = new th();
x.start();
while(true){ } //接收socket用
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.107.6
※ 编辑: starskgb 来自: 140.123.107.6 (04/03 17:10)