PTHREAD_JOIN32(), PTHREAD_JOIN64() The pthread_join32() and pthread_join64() forms are only valid in 64-bit pointer environments for OpenVMS Alpha. Ensure that your compiler provides 64-bit support before you use pthread_join64(). Causes the calling thread to wait for the termination of a specified thread.
1 – C Binding
#include <pthread.h> int pthread_join ( pthread_t thread, void **value_ptr);
2 – Arguments
thread Thread whose termination is awaited by the calling routine. value_ptr Return value of the terminating thread (when that thread either calls pthread_exit() or returns from its start routine).
3 – Description
This routine suspends execution of the calling thread until the specified target thread thread terminates. 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 the same thread, the results are unpredictable. A call to pthread_join() returns after the target thread terminates. The pthread_join() routine is a deferred cancelation point; the target thread will not be detached if the thread blocked in pthread_join() is canceled. If a thread calls this routine and specifies its own pthread_t, a deadlock can result. The pthread_join() (or pthread_detach()) routine 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 can be reclaimed. NOTE For OpenVMS Alpha systems: The pthread_join() routine is defined to pthread_join64() if you compile using /pointer_size=long. If you do not specify /pointer_size, or if you specify /pointer_ size=short, then pthread_join() is defined to be pthread_ join32(). You can call pthread_join32() or pthread_join64() instead of pthread_join(). The pthread_join32() form returns a 32-bit void * value in the address to which value_ptr points. The pthread_join64() form returns a 64- bit void * value. You can call either, or you can call pthread_join(). Note that if you call pthread_join32() and the thread with which you join returns a 64-bit value, the high 32 bits of which are not 0 (zero), the Threads Library discards those high bits with no warning.
4 – 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 thread specifies the calling thread.
5 – Associated Routines
pthread_cancel() pthread_create() pthread_detach() pthread_exit()