Java 程式設計 -- Thread (執行緒、線程)
Java 程式簡介運算式分枝迴圈陣列函數遞迴錯誤處理物件導向封裝繼承多型技巧函式庫字串數學正規表達式容器檔案網路資料庫視窗ThreadListener錯誤陷阱相關檔案相關資源教學錄影Eclipse考題解答訊息相關網站參考文獻最新修改簡體版English |
程式範例:SimpleThread.javaclass SimpleThread implements Runnable { String name; public static void main(String[] args) { SimpleThread a = new SimpleThread("A"); SimpleThread b = new SimpleThread("B"); Thread threada = new Thread(a); Thread threadb = new Thread(b); threada.start(); threadb.start(); } SimpleThread(String pName) { name = pName; } public void run() { for (int i=0; i<5; i++) { String line = name+":"+i; System.out.println(line); } } } 執行結果
|
page revision: 0, last edited: 09 Nov 2010 03:42
Post preview:
Close preview