Advanced Qt - A Deep Dive 4/6 Multithreading Part 2
summary
Explains concrete Qt concurrency patterns: create threads with QThread (run now calls exec by default) or use moveToThread and rely on the event loop, and avoid creating GUI objects off the main thread. Covers synchronization primitives and when to use them: QMutex with QMutexLocker for RAII unlocking, QReadWriteLock (useful only when three or more readers) and QSemaphore/QWaitCondition (wake requires holding a lock). Describes QThreadStorage for per-thread singletons, QAtomicInt for atomic refcounts, and a thumbnail-viewer exercise that fetches images on worker threads.
AI-written summary · about
chapters (15)
- 0:00Introduction to multithreading
- 1:52Synchronization with mutexes
- 4:43QMutexLocker convenience class
- 6:54Read-write locks explained
- 8:35Semaphores in Qt
- 10:00Condition variables for waiting
- 11:23Thread-local storage
- 13:32GUI operations and threads
- 15:01Memory management in threads
- 16:07Avoid blocking the GUI thread
- 17:57Thread safety vs reentrancy
- 20:22Implicitly shared types
- 21:46Atomic operations
- 22:08Canceling thread invocations
- 23:58Exercise multithreaded thumbnail viewer
related talks
58mMultithreading with Qt
01h 00mCreating multithreaded applications with Qt
47m“Multithreading is the answer. What is the question? (part 1 of 2)”
59mAn Introduction to Multithreading in C++20
01h 04mBack to Basics: Concurrency
01h 28mAn Introduction to Multithreading in C++20
01h 08mBetter Code: Concurrency
01h 14mMultithreading in UI application: When some threads are more equal than others
