Advertisement Jump to content
Sign in to follow this  
Fish Fishes

Critical sections in window threads

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

Advertisement
You only need to use critical sections in that piece of code when other threads are accessing pObject. If pObject is bound to 1 single thread, there is no need to use Critical Sections, as it will slow things down(Very little tho).

Critical Sections(Also called Mutexes) are used to "lock" data from being used by 2 threads at the same time. If one thread is reading and the other thread is writing, data might get mixed up, and output will be corrupted or your application crashes.

Toolmaker

Share this post


Link to post
Share on other sites
If two threads might try to delete pObject at the same time then it's not only valid it's required.

The thing is, if you don't do it then your program might work anyway *most* of the time. But every once in a while it will crash with a corrupt heap because pObject will be deleted a second time before the first thread can finish NULL'ing it.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!