Causes the calling thread to wait for the termination of a specified thread.
pthread_join( thread, value_ptr );
Argument Data Type Accessthread opaque pthread_t read value_ptr void * write
#includeint pthread_join ( pthread_t thread, void **value_ptr);
A call to a pthread_join routine returns after the specified thread terminates. The pthread_join routine is a deferred cancellation point: the target thread will not be detached if the thread blocked in pthread_join is canceled.
On return from a successful pthread_join call with a non-NULL value_ptr argument, the value passed to pthread_exit is returned in the location referenced by value_ptr, and the terminating thread is detached. If more than one thread attempts to join with a single thread, the results are unpredictable.
If a thread calls this routine and specifies its own pthread_
t
, a deadlock can result.
The pthread_join (or pthread_detach) function should eventually be called for every thread that is created with the detachstate attribute of its thread object set to PTHREAD_CREATE_JOINABLE, so that storage associated with the thread may be reclaimed.
For OpenVMS Alpha systems only, you can call pthread_join32 or
pthread_join64 instead of pthread_join. The pthread_join32 form
returns a 32-bit "void *
" in the address to which
value_ptr points. The pthread_join64 form returns a 64-
bit "void *
". You can call either, or you can call
pthread_join. The pthread_join routine is defined to pthread_join64
if you compile using /pointer_size=long
. If you you
do not specify /pointer_size
, or if you specify
/pointer_size=short
, then pthread_join is defined to be
pthread_join32
Return Description0 Successful completion. [EINVAL] The value specified by thread does not refer to a joinable thread. [ESRCH] The value specified by thread does not refer to an existing thread ID. [EDEADLK] A deadlock was detected, or the value of thread specifies the calling thread.
pthread_cancel pthread_create pthread_detach pthread_exit