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


pthread_join


pthread_join32, pthread_join64
The pthread_join32 and pthread_join64 forms are only valid in 64-pointer environments for OpenVMS Alpha. For information regarding 32- and 64-bit pointers, see Appendix B. Ensure that your compiler provides 64-bit support prior to using pthread_join64.

Causes the calling thread to wait for the termination of a specified thread.

Syntax

pthread_join(
             thread,
             value_ptr );
 


Argument Data Type Access

thread opaque pthread_t read value_ptr void * write


C Binding

#include 

int pthread_join ( pthread_t thread, void **value_ptr);

Arguments

thread
Thread whose termination is awaited by the caller of this routine.
value_ptr
Return value of the terminating thread (when that thread calls pthread_exit or returns.)

Description

This routine suspends execution of the calling thread until the specified target thread terminates.

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 Values

If an error condition occurs, this routine returns an integer indicating the type of error. Possible return values are as follows:
Return        Description

0 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.


Associated Routines

   pthread_cancel
   pthread_create
   pthread_detach
   pthread_exit



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