17.2.1.  Thread Safety and QObjects

[ fromfile: threads.xml id: threadsafety ]

  1. QMutex, for mutual exclusion, along with QMutexLocker, enables an individual thread T to protect (lock) an object or a section of code so that no other thread can access it until T releases (unlocks) it.

  2. QWaitCondition, combined with QMutex, can be used to put a thread into a non-busy block state where it can wait for another thread to wake it up.

  3. A QSemaphore is a more generalized QMutex for situations where a thread may need to lock more than one resource before doing its work. Semaphores make it possible to ensure that a thread locks resources only when enough are available for it to do its job.

There are more examples demonstrating how to use QtConcurrent in the Qt examples: $QTDIR/examples/qtconcurrent.