[THREAD] reveiller un thread qui dort
Bonjour
J'ai un tread qui effectue un boucle for et qui fait une pause a chaque tour
de boucle. Je cherche en vain à reveiller le thread lorsque j'en ai besoin.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public class CheckPrinc extends Thread
{
public void run()
{
for(;;){
...
this.pause();
}
}
public void awake(){
synchronized(this){
this.notifyAll();//this.notify() --> meme chose
}
}
public void pause(){
try {
this.sleep(timer);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
Lorsque j'appelle awake() il attend qand même la fin de sleep (du timer donc)
Merci d'avance pour votre aide