62,620
社区成员
发帖
与我相关
我的任务
分享
Thread-10 a
Thread-9 a
Thread-8 a
Thread-7 a
Thread-6 a
Thread-5 a
Thread-4 a
Thread-3 a
Thread-2 a
Thread-1 a
ddd
Thread-0 a
Thread-0zuihou0
Thread[] threads = new Thread[10];
for(int i=0; i<10; i++){
final int index = i;
threads[i] = new Thread(){
public void run(){
try{
Thread.sleep(1000 * index);
}catch(InterruptedException e){
}
System.out.println("Thread " + index);
}
};
threads[i].start();
}
for(int i=0; i<10;i++){
try{
threads[i].join();
}catch(InterruptedException e){
}
}
//10个线程都执行完
System.out.println("done");
Thread t1=new Thread("aaa");
if(t1.isAlive)
{
System.out.print("yes");
}