How to manually kill a specific (running) thread from Visual Studio

For testing, do I need to manually kill the named thread (in a debugging session) from Visual Studio - or any other tool that allows me to do this?

But the Threads Debug Window in Visual Studio 2010 has the Freeze option in the thread context menu and only Sysinternal ProcessExplorer lists the processes, not the threads.

Is there a way to manually kill a specific (running) thread?

+4
source share
1 answer

It’s not easy to just kill the thread because the language developers want to avoid the following problem: your thread takes the lock, and then you kill it before it can release it ... now anyone who needs this lock will be stuck.

What you need to do is use some global variable to stop the thread. You must manually, in your stream code, check that the global variable and return, if you see, that means you have to stop.

+2
source

Source: https://habr.com/ru/post/1443027/


All Articles