1 .TH PTHREAD_JOIN 3 LinuxThreads
4 pthread_join \- wait for termination of another thread
9 int pthread_join(pthread_t th, void **thread_return);
12 !pthread_join! suspends the execution of the calling thread until the
13 thread identified by |th| terminates, either by calling !pthread_exit!(3)
14 or by being cancelled.
16 If |thread_return| is not !NULL!, the return value of |th| is stored
17 in the location pointed to by |thread_return|. The return value of
18 |th| is either the argument it gave to !pthread_exit!(3), or
19 !PTHREAD_CANCELED! if |th| was cancelled.
21 The joined thread !th! must be in the joinable state: it must not have
22 been detached using !pthread_detach!(3) or the
23 !PTHREAD_CREATE_DETACHED! attribute to !pthread_create!(3).
25 When a joinable thread terminates, its memory resources (thread
26 descriptor and stack) are not deallocated until another thread
27 performs !pthread_join! on it. Therefore, !pthread_join! must be
28 called once for each joinable thread created to avoid memory leaks.
30 At most one thread can wait for the termination of a given
31 thread. Calling !pthread_join! on a thread |th| on which another
32 thread is already waiting for termination returns an error.
36 !pthread_join! is a cancellation point. If a thread is canceled while
37 suspended in !pthread_join!, the thread execution resumes immediately
38 and the cancellation is executed without waiting for the |th| thread
39 to terminate. If cancellation occurs during !pthread_join!, the |th|
40 thread remains not joined.
43 On success, the return value of |th| is stored in the location pointed
44 to by |thread_return|, and 0 is returned. On error, a non-zero error
50 No thread could be found corresponding to that specified by |th|.
53 The |th| thread has been detached.
56 Another thread is already waiting on termination of |th|.
59 The |th| argument refers to the calling thread.
62 Xavier Leroy <Xavier.Leroy@inria.fr>
68 !pthread_attr_setdetachstate!(3),
69 !pthread_cleanup_push!(3),
70 !pthread_key_create!(3).