?? machine.java
字號:
package withex;
public class Machine extends Thread{
public void run(){
for(int a=0;a<3;a++){
System.out.println(currentThread().getName()+":"+a);
if(a==1 && currentThread().getName().equals("m1"))
throw new RuntimeException("Wrong from Machine");
try{
sleep(100);
}catch(InterruptedException e){throw new RuntimeException(e);}
}
}
public static void main(String args[])throws Exception{
Machine machine=new Machine();
machine.setName("m1");
machine.start();
machine.run();
System.out.println("Is machine alive:"+machine.isAlive());
System.out.println("main:end");
}
}
/****************************************************
* 作者:孫衛琴 *
* 來源:<<Java面向對象編程>> *
* 技術支持網址:www.javathinker.org *
***************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -