lundi 23 juillet 2018

How to "stop" detached thread which is waiting on a condition variable?

I detach a thread from Class B:

t1 = std::thread(&Class::method, this);
t1.detach();

which as part of it's normal operation waits on a condition variable:

cv.wait(lock);

However, when I close my B application the detached thread remains. How do I stop/clean-up this thread when B::~B() is called?

Aucun commentaire:

Enregistrer un commentaire