可能的重复:
终止的线程复兴
Thread threadWait = new Thread()
{
@Override
public void run() {
try {
sleep(10000);
sync = false;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
我在这里调用这个线程:
threadWait.start();
while(sync){
//do something
}
当 threadWait 完成时,状态为 TERMINATED。我如何才能再次启动线程?任何想法?谢谢大家!
解决方案:
Runnable runWait = new Runnable(){
public void run(){
try {
Thread.sleep(10000);
sync = false;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
和..
Thread first = new Thread(runWait);
first.start();