?? multithreaddemo1.java
字號:
/* * MultiThreadDemo1.java * 參見教程282頁 示例程序10-1 * Created on 2005年8月14日, 下午5:03 */package jbookch10;public class MultiThreadDemo1 { public static void main(String args[]){ //運行子線程 new NewThread("1"); new NewThread("2"); new NewThread("3"); new NewThread("4"); //運行主線程 System.out.print(" 主線程啟動! "); for (int i=0;i<100; i++) { System.out.print(" --> "); } System.out.print(" 主線程結束! "); }}class NewThread implements Runnable { NewThread(String threadName) { name=threadName; t= new Thread(this,name); System.out.print(" 新線程"+name+"啟動! "); t.start();//啟動線程 } //線程入口 public void run() { for (int i=0;i<100; i++) { System.out.print(name); } System.out.print(" 線程"+name+"結束! "); } private Thread t; private String name; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -