package com.test.concurrent;
public class SimpleThread extends Thread {
private static int counter=0;
private int countDown=5;
public SimpleThread(){
super(String.valueOf(counter++));
run();
}
public void run(){
while(true){
if(countDown--==0){
return;
}
System.out.println("#"+getName()+" "+this+" countDown:"+countDown);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=0;i<5;i++){
new SimpleThread();
}
}
}
Thinking in Java學習筆記,簡單包裝Thread,實現快速實現線程
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.