[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


2.1.2 Terminating a Thread

A thread exists until it terminates and the thread has been detached. If the thread terminates before it is detached, then the thread continues to exist and other threads can join with it. Threads can be created in detached state, threads can be detached by calling pthread_detach, and are automatically detached when pthread_ join returns.


Note
When the initial thread returns from the main routine, the entire process (on UNIX systems) or image (on OpenVMS systems) terminates, just as it does when a thread calls exit() (on systems based on UNIX software) or SYS$EXIT (on OpenVMS systems).

A thread terminates for any of the following reasons: