QWaitCondition 2. qwaitcondition

Source: Internet
Author: User

QWaitCondition 2. qwaitcondition

 

This article is original. If it is referenced, please specify the source

  • Q: Which threads does the QWaitCondition wake () and wakeall () functions wake up?

Can the suspended threads caused by various objects in this class be awakened globally?

A: No. I wrote an example to prove that:

QWaitCondition only wakes up by A thread blocked by A specific QWaitCondition object (for example, A). It can be awakened through A. wakeOne (), or A. wakeAll.

If necessary, leave a message and upload the example.

 

  • I personally think there are two ways to synchronize threads

Active mode, such as mutex and semaphores. Features: The blocked thread can actively detect whether it can run and does not need to be awakened

Passive mode, such as QWaitCondition. Features: The thread is blocked, and the blocked thread is activated through wake/wakeall to continue running as conditions permit.

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.