Page 1 of 1

Why you should never suspend a thread

Posted: Wed Nov 12, 2008 5:30 am
by Mistrel
I thought it was a good read. I hadn't considered that a thread might get paused before releasing a mutex lock.

For example, even if your thread has no mutex locks a function you're calling may. LoadLibrary/OpenLibrary for example will deadlock if it doesn't return and you try to open another library in a different thread.

It's best to signal your thread to suspend from the inside and resume from outside.

http://blogs.msdn.com/oldnewthing/archi ... 55988.aspx

Posted: Wed Nov 12, 2008 1:08 pm
by Psychophanta
Common sense says me that a thread must be ended or suspended only by itself.
A way is just to use from outside a signal to send to it to tell to be finished.