重複の可能性:
終了したスレッドの復活
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になります。スレッドをもう一度開始するにはどうすればよいですか?何か案が?THX TO ALL!
解決:
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();