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. If multiple threads call this routine and specify the same thread, all threads resume execution when the specified thread terminates.
If you specify the current thread with the pthread_join( ) routine, a deadlock results.
Do not confuse pthread_join( ) with other routines that cause waits and that are related to the use of a particular multithreading feature. For example, use pthread_cond_wait( ) or pthread_cond_timedwait( ) to wait for a condition variable to be signaled or broadcast.