如何判断线程已执行完毕
答案:1 悬赏:0
解决时间 2021-01-06 05:38
- 提问者网友:却不属于对方
- 2021-01-05 10:28
如何判断线程已执行完毕
最佳答案
- 二级知识专家网友:青灯有味
- 2021-01-05 11:40
其中一个线程?使用类变量判断就可以了。
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;
}
}
}
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;
}
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯