[問題] thread+呼叫外部程式
當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)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):