- UID
- 1066743
|
Thread和Runnable的API(5)
7.开发中一般不使用interrupt()而在类中增加isStop属性来标志是否结束while循环
class MyThread extends Thread{
private volatile boolean isStop = false;
@Override
public void run() {
int i = 0;
while(!isStop){
i++;
}
}
public void setStop(boolean stop){
this.isStop = stop;
}
} |
|