Thread Support in Qt
Qt provides thread support in the form of platform-independent threading classes, a thread-safe way of posting events, and signal-slot connections across threads. This makes it easy to develop portable multithreaded Qt applications and take advantage of multiprocessor machines. Multithreaded programming is also a useful paradigm for performing time-consuming operations without freezing the user interface of an application.
Earlier versions of Qt offered an option to build the library without thread support. Since Qt 4.0, threads are always enabled.
- Recommended Reading
- The Threading Classes
- Starting Threads with QThread
- Synchronizing Threads
- Reentrancy and Thread-Safety
- Threads and QObjects
- Concurrent Programming
- Thread-Support in Qt Modules
This document is intended for an audience that has knowledge of, and experience with, multithreaded applications. If you are new to threading see our Recommended Reading list:
- Threads Primer: A Guide to Multithreaded Programming
- Thread Time: The Multithreaded Programming Guide
- Pthreads Programming: A POSIX Standard for Better Multiprocessing
- Win32 Multithreaded Programming
The Threading Classes
These classes are relevant to threaded applications.
The <QtConcurrentRun> header provides a way to run a function in a separate thread.
Concurrent Filter and Filter-Reduce
The <QtConcurrentFilter> header provides concurrent Filter and Filter-Reduce.
Concurrent Map and Map-Reduce
The <QtConcurrentMap> header provides concurrent Map and MapReduce.
Platform-independent atomic operations on integers
Template class that provides platform-independent atomic operations on pointers
Represents the result of an asynchronous computation
Convenience class that simplifies QFuture synchronization
Allows monitoring a QFuture using signals and slots
Access serialization between threads
Convenience class that simplifies locking and unlocking mutexes
Convenience class that simplifies locking and unlocking read-write locks for read access
The base class for all runnable objects
General counting semaphore
Manages a collection of QThreads
Per-thread data storage
Condition variable for synchronizing threads
Convenience class that simplifies locking and unlocking read-write locks for write access
High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives
Note: Qt's threading classes are implemented with native threading APIs; e.g., Win32 and pthreads. Therefore, they can be used with threads of the same native API.
© 2012 Nokia Corporation and/or its subsidiaries. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Documentation sources may be obtained from www.qt-project.org.