creer un thread a partir d'un thread
bonjour,
j'aimerai pouvoir lancer un thread a partir d'un thread qui tourne en permanance:
on aurai donc la situation suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11
| public class Thread1 extends Thread(){
private int numero_thread=0;
public void run() {
while(true){
new thread2(numero_thread);
numero_thread++;
sleep(500);
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public class Thread2 extends Thread(){
private int numero,lancement=1;
public Thread2(int numero_thread){
this.numero=numero_thread;
}
public void run() {
while(true){
System.out.println("thread n°"+this.numero+" // lancement n°"+this.lancement);
this.lancement++;
sleep(300);
}
}
} |
mon problème est que quand on crée le thread2, le thread1 reste bloqué alors qu'il devrait continuer indéfiniment.
merci...