[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


2.1.4 Waiting for a Thread to Terminate

A thread waits for the termination of another thread by calling the pthread_join routine. Execution in the current thread is suspended until the specified thread terminates. Behavior is undefined if multiple threads call pthread_join and specify the same thread. This is because completion of the first join will detach the target thread.

If you specify the current thread with the pthread_join routine, a deadlock results. See Section 3.6.3 for more information about deadlocks.

Do not confuse pthread_join with other routines that cause waits and that are related to the use of a particular DECthreads feature. For example, use the pthread_cond_wait or pthread_cond_timedwait routines to wait for a condition variable to be signaled or broadcasted. (See Section 2.3.2 for more information on condition variables.)