[問題] thread+呼叫外部程式

看板java作者 (Metal)時間18年前 (2008/04/03 17:08), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
當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)
文章代碼(AID): #17z9wTnx (java)
文章代碼(AID): #17z9wTnx (java)