如何判断线程已执行完毕

发布网友

我来回答

1个回答

热心网友

其中一个线程?使用类变量判断就可以了。

class A{
static boolean aStop = false;

static void test(){
new AThread().start();

while(! aStop){
}
System.out.println("AThread stoped.");

}

class AThread extends Thread{
public void run(){
/////////////////////////
aStop = true;

}

}

}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com