#include <pthread.h>
|
int
pthread_join (pthread_t thrHandle, void **retValPtr); |
On return from a successful pthread_join call with a non-NULL retValPtr argument, the value passed to pthread_exit by the terminating thread is stored in the location referenced by retValPtr. When a pthread_join returns successfully, the target thread has been terminated. The results of multiple simultaneous calls to pthread_join specifying the same target thread are undefined.
/* Thread’s function. */ void *a_thread_func_1_1(void*) { int i; printf("Wait for 3 seconds for thread to finish execution:0); for(i=1;i<4;i++) { printf("Waited (%d) second0, i); sleep(1); } return NULL; } int XYZ() { pthread_t new_th; /* Create a new thread. */ if(pthread_create(&new_th, NULL, a_thread_func_1_1, NULL) != 0) { perror("Error creating thread\n"); return -1; } /* Wait for thread to return */ if(pthread_join(new_th, NULL) != 0) { perror("Error in pthread_join()\n"); return -1; }
[EINVAL] | |
The implementation has detected that the value specified by thrHandle does not refer to a joinable thread. or some other thread has already joined | |
[ESRCH] | |
No thread could be found corresponding to that specified by the given thread ID, thrHandle. | |
[EDEADLK] | |
A deadlock was detected or the value of thrHandle specifies the calling thread. | |
© 2005-2007 Nokia |