diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index b5b4618e0bd..571fc015bb6 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -470,6 +470,16 @@ QThread::~QThread() \threadsafe Returns \c true if the thread is finished; otherwise returns \c false. + A thread is considered finished if it has returned from the run() function + and the finished() signal has been emitted. + +//! [execution-after-finished] + Note the thread may still run for arbitrary amount of time after the + finished() signal is emitted, running clean-up operations such as executing + the destructors to \c{thread_local} variables. To synchronize with all + effects from the thread, call wait() and verify it returned true. +//! [execution-after-finished] + \sa isRunning() */ bool QThread::isFinished() const @@ -483,6 +493,11 @@ bool QThread::isFinished() const \threadsafe Returns \c true if the thread is running; otherwise returns \c false. + A thread is considered to be running if QThread has been started with + start() but is not yet finished. + + \include qthread.cpp execution-after-finished + \sa isFinished() */ bool QThread::isRunning() const @@ -924,6 +939,12 @@ QThread::Priority QThread::priority() const This provides similar functionality to the POSIX \c pthread_join() function. + \note On some operating systems, this function may return true while the + operating system thread is still running and may be executing clean-up code + such as C++11 \c{thread_local} destructors. Operating systems where this + function only returns true after the OS thread has fully exited include + Linux, Windows, and Apple operating systems. + \sa sleep(), terminate() */ bool QThread::wait(QDeadlineTimer deadline)