Monthly Archives: November 2006

Join() in the context of threads

Note from Boost.Thread:

Just as the lifetime of a file may be different from the lifetime of an iostream object which represents the file, the lifetime of a thread of execution may be different from the thread object which represents the thread of execution. In particular, after a call to join(), the thread of execution will no longer exist even though the thread object continues to exist until the end of its normal lifetime. The converse is also possible; if a thread object is destroyed without join() first having been called, the thread of execution continues until its initial function completes.


void join();
Requires *this is joinable.
Effects The current thread of execution blocks until the initial function of the thread of execution represented by *this finishes and all resources are reclaimed.
Notes If *this == thread() the result is implementation-defined. If the implementation doesn’t detect this the result will be deadlock.