Jump to content
  • Advertisement
Sign in to follow this  
Escarab

end thread externally(C++)

This topic is 3791 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!