Adelsbach Enhanced Threading Library

Manual Pages (DD-00013-001)

Enhanced Threading Library > thrd_join (3)
HTML TXT PDF PS
thrd_join(3) Library Functions Manual thrd_join(3)

thrd_joindetach thread

library “threads”
#include <threads.h>

int
thrd_join(thrd_t thrd, int *res);

The function () will suspend the execution of the current thread and will wait for the given thread thrd to finish executing. The exit status of the given thread as set by thrd_exit(3) can then be retrieved by the res argument if it is not NULL.

The given thread must not have been detached by thrd_detach(3) and must be a member of the current process.

If the given thread has already been terminated and () has not yet been called for the given thread before, the exit status can be retrieved without the function blocking.

If multiple threads call () for the same thread they all will wait for execution of the given thread, however only one of the threads will retrieve the exit status.

The function thrd_join() returns thrd_success on success. If the res argument is not NULL it will populate the integer pointed to by the argument with the exit status of the joining thread. In case of an error thrd_error if an error has occurred.

thrd_create(3) thrd_exit(3) thrd_yield(3) thrd_equal(3) thrd_detach(3) thrd_current(3) thrd_sleep(3)

The thrd_join() function first appeared in the C11 standard ISO/IEC 9899:2011.

Jan Adelsbach <jan@jadelsbach.de>

May 9, 2020 Debian