For the purpose of testing, I need to manually kill a named thread (in a debugging session) from Visual Studio - or any other tool that allows me to do that?
But the Threads
Debug Window in Visual Studio 2010 only has a Freeze
option in the thread's context menu, and Sysinternal's ProcessExplorer only lists processes, not threads.
Is there a way to manually kill a specific (running) thread?
It's not easy to just kill a thread because the designers of the language want to avoid the following problem: your thread takes a lock, and then you kill it before it can release it... now anyone who needs that lock will get stuck.
What you have to do is use some global variable to tell the thread to stop. You have to manually, in your thread code, check that global variable and return if you see it indicates you should stop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With