What a thread returns (with return
or pthread_exit
) can be
accessed by its parent with a pthread_join
function. The operating system does not
return the control to a invocation on pthread_join
until the thread on which it was
invoked has completed execution. And so, the only way for a thread to transform data that another thread
is processed exclusively during its execution; after the execution of the thread, they are released.
#include <pthread.h>
int pthread_join(pthread_t thread, void **retval);
//Compile and link with -pthread.