Waits for a thread to terminate.
#include <thread.h> int thr_join ( thread_t wait_for, thread_t *dead, void **status);
(IN) Specifies the thread to wait for. To join the next available thread, set it to 0.
(OUT) Points to the location of the ID of the thread that was terminated. This parameter can be NULL.
(OUT) Points to the location where the application-defined status of the terminated thread is returned. This parameter can be NULL.
If successful, returns 0. Otherwise, returns one of the following error codes:
Only joinable application threads can be joined by calling thr_join. When a joinable thread exits and a thread is not already waiting to join the exiting thread, the system maintains sufficient state to support subsequent calls to thr_join. If you do not call thr_join on an exited joinable thread, system resources are held up unnecessarily.