jeudi 16 juillet 2020

Throw an exception to a worker thread C++11

I have a bunch of worker threads which I would need to stop from the main thread. As C++11 does not allow to terminate a thread from outside, I would like to throw an exception to each one of them so that they can close on their own. I found a lot of answers on the opposite (catch exceptions thrown in worker threads inside the main one, as in here: How can I propagate exceptions between threads?), but I need to do exactly the opposite! Any ideas?

Thanks, Michele

Aucun commentaire:

Enregistrer un commentaire