Stopper un thread pour ensuite le redémarrer
Bonjour
je viens de créer 3 thread chacun execute un traitement je veux stopper un thread pour ensuite le démarrer.voici mon essai qui n'a pas donner grande chose
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public class TestThread {
@SuppressWarnings("deprecation")
public static void main(String[] args) {
// TODO Auto-generated method stub
FirstThread t1= new FirstThread("test");
FirstThread t2 = new FirstThread("xxxxx");
FirstThread t3= new FirstThread("yyyyyy");
t1.start();t2.start();
t3.start();
t3.stop();
//t3.suspend();
//t3.interrupt();
}
} |
et j'ai comme résultat les 3 thread qui tourne sans cesse jusqu'à ce que le traitement prend fin.voici 3 thread qui affichent un compteur .meme si j'essai d'en stopper un d'entre eux, je ne parviens pas à le faire
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| Thread nommé : test - itération : 22
Thread nommé : yyyyyy - itération : 22
Thread nommé : xxxxx - itération : 22
Thread nommé : test - itération : 23
Thread nommé : yyyyyy - itération : 23
Thread nommé : xxxxx - itération : 23
Thread nommé : test - itération : 24
Thread nommé : xxxxx - itération : 24
Thread nommé : yyyyyy - itération : 24
Thread nommé : test - itération : 25
Thread nommé : yyyyyy - itération : 25
Thread nommé : xxxxx - itération : 25 |
comment stopper le thread t3 par exemple
merci