mthread_p mthr_join(mthread_p tp, int *exitloc);
If exitloc is not a null pointer, the exitvalue of the terminated thread will be stored at this location.
Only nondetached threads could be joined. Detached threads are destroyed when calling mthr_exit(3) whereas non detached threads are converted to zombie threads. mthr_join() frees this zombies and returns thier exitvalue. Moreover only one thread could successfully join a thread. All other calls with the same value for tp will return prematurely.
As it's senseless for a thread to wait for its own termination, calls to mthr_join() with tp equal to the calling thread's handle are not allowed.