?? twofruit.java
字號:
class FruitThread extends Thread{
public FruitThread(String str){ //編寫子類的構造方法
super(str);
}
public void run(){ //定義線程體,編寫線程代碼
for(int i=0;i<5;i++){
System.out.println(i+""+getName()); //getName()為獲得當前線程名稱
try{
sleep((int)(Math.random()*1000));
}catch(InterruptedException e){ }
}
System.out.println("Done!"+getName());
}
}
class TwoFruit{
public static void main(String args[]){
new FruitThread("蘋果").start();
new FruitThread("香蕉").start();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -