• Advertisement
Sign in to follow this  

end thread externally(C++)

This topic is 3645 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I externally terminates a thread created by the _beginthread()function? thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Generally speaking, it's bad form to end a thread "externally," as that thread may be in the middle of any number of operations that should be cleaned up (file io, memory allocation, etc.). What you should do is provide a safe way to communicate with your thread that it should quit whatever it's doing, such as a shared atomic of some sort (could conceivably just be a bool, or an event/semaphore). Your external thread sets this to true when it wants the thread to end, and the thread checks this at various points when it is safe to terminate.

If you really really have to end the thread externally, there are ways... under windows you can call TerminateThread... I'm not sure if there is an equivalent for the "_beginthread" API.

Share this post


Link to post
Share on other sites
Thak you, i think i will use some sort of sinalization to terminates my thread.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement