看板 java 關於我們 聯絡資訊
like this ? class Test implements Runnable{ private int time; public Test(int time){ this.time=time; } public void run(){ try{ Thread.sleep(time); } catch(InterruptedException e){} /* 一些判斷,不然一直執行會有生不完的 Thread */ new Thread(new Test(2000)).start(); } } public class ThreadEx{ public static void main(String[] args){ Test ta = new Test(1000); Thread t1 = new Thread(ta); t1.start(); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.39.75 ※ 編輯: darkk6 來自: 140.116.39.75 (09/08 17:37)
spiderman007:感謝你的回答....有幫助到我! 09/08 18:07
terrybob:推,受教了 09/08 18:15
gmoz:推 09/08 21:25