I have an implementation where I need to communicate over a network while a job is running.
The way I am doing is that, the main thread creates a seperate thread for doing the job. Now until the seperate thread is running, the main thread will continue to send packets over the network. Once the second thread finishes, it should join back to the main thread and terminate.
I've been trying to search how to do "Once the second thread finishes" part but couldn't get any clean implementation. I am hoping of something like thread.has_finished() boolean function, to know whether I should call thread.join() or not.
Any ideas?
(Library being used is standard c++ thread library)
Aucun commentaire:
Enregistrer un commentaire