java多线程的问题为何输出结果只有一个?
publicclassThreadDD{publicstaticvoidmain(String[]args){Threadtt=newTestThread();tt.st...
public class ThreadDD {
public static void main(String []args){
Thread tt=new TestThread();
tt.start();
int index=0;
while(true){
if(index++==100)
try{tt.join();}catch(Exception e){}
System.out.println("main"+Thread.currentThread().getName());
}
}
}
class TestThread extends Thread {
public void run() {
while (true) {
System.out.println("run" + Thread.currentThread().getName());
}
}
} 展开
public static void main(String []args){
Thread tt=new TestThread();
tt.start();
int index=0;
while(true){
if(index++==100)
try{tt.join();}catch(Exception e){}
System.out.println("main"+Thread.currentThread().getName());
}
}
}
class TestThread extends Thread {
public void run() {
while (true) {
System.out.println("run" + Thread.currentThread().getName());
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询