Waits for a thread to terminate.
#include <pthread.h>
int pthread_join (
pthread_t thread,
void **status);
(IN) Specifies the thread to wait for.
(OUT) Points to the location where the application-defined status of the terminated thread is returned. This can be NULL.
If successful, returns 0. Otherwise, returns a nonzero error code:
Only joinable application threads can be joined by calling pthread_join. When a joinable thread exits and a thread is not already waiting to join the exiting thread, the system maintains sufficient state to support subsequent calls to pthread_join. If you do not call pthread_join on an exited joinable thread, system resources are held up unnecessarily.