内容

Qt 中的线程支持

Qt 提供线程支持按平台无关形式 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

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:

线程类

这些类有关线程化应用程序。

Asynchronous Run

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.

QAtomicInt

于整数上独立于平台的原子操作

QAtomicPointer

Template class that provides platform-independent atomic operations on pointers

QFuture

表示异步计算的结果

QFutureSynchronizer

简化 QFuture 同步的方便类

QFutureWatcher

允许监视 QFuture 使用信号和插槽

QMutex

在线程之间串行化访问

QMutexLocker

Convenience class that simplifies locking and unlocking mutexes

QReadLocker

Convenience class that simplifies locking and unlocking read-write locks for read access

QReadWriteLock

读写锁

QRunnable

用于所有可运行对象的基类

QSemaphore

通用计数信号量

QThread

独立于平台的线程管理办法

QThreadPool

管理 QThread 的集合

QThreadStorage

每线程数据存储

QWaitCondition

用于同步线程的条件变量

QWriteLocker

Convenience class that simplifies locking and unlocking read-write locks for write access

QtConcurrent

High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives

注意: 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.