bool QThread::wait(unsigned long time = ULONG_MAX)

いずれかの条件を満たすまで、スレッドをブロックする:

  • スレッドに関連付けられた QThread オブジェクトが実行を終了する (run() から復帰した時など)。この関数は、スレッドが終了すると true を返す。また、スレッドがまだ開始されていない場合は true を返す。

  • time ミリ秒を過ごす。time が ULONG_MAX (デフォルト) の場合, 待ち状態はタイムアウトしない。(スレッドは run() から復帰しなければならない)。この関数は、待ち状態がタイムアウトすると false を返す。

これは POSIX の pthread_join() 関数に近い機能を提供する。

参考 sleep() と terminate()

Blocks the thread until either of these conditions is met:

The thread associated with this QThread object has finished execution (i.e. when it returns from run()). This function will return true if the thread has finished. It also returns true if the thread has not been started yet.

time milliseconds has elapsed. If time is ULONG_MAX (the default), then the wait will never timeout (the thread must return from run()). This function will return false if the wait timed out.

This provides similar functionality to the POSIX pthread_join() function.

See also sleep() and terminate().