下面的代码有点问题,但不知道是什么原因,请大侠指点迷经
public class Test001 extends Thread
{
private int countDown=5;
private static int threadCount=0;
public Test001(){
super(""+ ++threadCount);
start();
}
public String toString(){
return "#"+getName()+":"+countDown;
}
public void run(){
while(true){
System.out.println(this);
if(--countDown==0) return;
}
}
public static void main(String[] args){
new Test001(Thread.MAX_PRIORITY);
for(int i=0;i<5;i++){
new Test001(Thread.MIN_PRIORITY);
}
}
}
public class Test001 extends Thread
{
private int countDown=5;
private static int threadCount=0;
public Test001(){
super(""+ ++threadCount);
start();
}
public String toString(){
return "#"+getName()+":"+countDown;
}
public void run(){
while(true){
System.out.println(this);
if(--countDown==0) return;
}
}
public static void main(String[] args){
new Test001(Thread.MAX_PRIORITY);
for(int i=0;i<5;i++){
new Test001(Thread.MIN_PRIORITY);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货