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.