Disadvantages of mutex lock

Source: Internet
Author: User
Mutex lock has some disadvantages: for example, what if you forget to unlock the mutex lock? In this case, any process that tries to lock the mutex lock that has been locked can wait for a long time. These threads become dead (zombie thread). This is a technical term, that is, a thread that exists but cannot do anything. Obviously, we don't want this to happen.

There is another problem with the mutex lock. Let's see what will happen in the following situations?
If the two threads depend on the same object (for example, the state of the game player, this state will be accessed for each frame. In a normal game, the Access frequency is about 30 ~ per second ~ 60 times ). At the same time, another thread needs to perform a lot of processing on this status (ifProgramThis function is not efficient, and the processing process takes up to 30 seconds. It is assumed that it can lock the mutex lock at any time, even if it does not use the locked object ). The first thread requires a lot of update information, but it actually stops for a long time, because it will wait until the second thread completes, so the game looks lagging.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.