Why you should never suspend a thread

Everything else that doesn't fall into one of the other PB categories.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Why you should never suspend a thread

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply