Jump to content
  • Advertisement
Sign in to follow this  
fathom88

Question on Threads in VC++

This topic is 4005 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

I'm modifying someone's code. I see they use CreateThread to spawn processing threads. They use an event to trigger an exit for the threads. I noticed they use the same m_hProcThread everytime they do a CreateThread. However, they never call CloseHandle on the thread handle. Is this correct? Or is it just a style thing? I don't want to change anything if I don't have to. I don't like to disturb people's code. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
This isn't invalid, when a process terminates, all open handles are closed and all running threads are terminated1. It's just not tidy.

Skizz

1. It is possible to have a deadlock on exit.

Share this post


Link to post
Share on other sites
It's a bit like littering. Yes, someone will clean up after you. No, you shouldn't do it.

Share this post


Link to post
Share on other sites
Note that you can immediately close the handle if you don't actually need it, and then there is nothing to clean up.

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!