Bonjour ,
J'ai 3 thread a executer
Un thread envoie
un thread reception
un thread reception2
Les 3 sont liés a des fonctions qui ont des boucles infinis
Lorsque l'on envoie , on a reception ensuite , puis si on a reception on a reception 2 et tout ça à l'infini .
Cependant , je n'arrive pas à faire cela .
J'ai fais un truc comme ça :
J'espère que vous sauriez m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 pthread_create(&envoi, NULL, thread_envoi,(void*)NULL); pthread_join(envoi,NULL); // On attend que envoi finit pthread_create(&reception, NULL, thread_reception,(void*)NULL); pthread_join(reception,NULL); // on attend qu'il finisse pthread_create(&reception2,NULL,thread_reception2,(void*)NULL); pthread_join(reception2,NULL); // on attend qu'il finisse
Edit : Apparement , vu que ce sont des boucles infinis , cela bloque des l'attente du thread envoi .
Edit2 : J'ai pensé à enlever les pthread_join() : Cependant , les trois threads s'exécutent directement et le programme se finit .
Y a t il une solution contre ça ?
Partager