By now, you should have begun to realize that although the pthread_join(3) and wait(2) (and family) APIs seem to be very similar, they are certainly not equivalent; several differences between them exist and are enumerated in the following table:
Situation |
Thread : pthread_join(3) |
Process: wait[pid](2) |
Condition |
A thread being waited for must have its detached state attribute set as joinable, not detached. |
None; any child process can (and in fact must) be waited upon (recall our fork rule #7) |
Hierarchy |
None: any thread can join on any other thread; there is no requirement of a parent-child relationship. In fact, we do not consider threads to live within a strict parent-child ... |