![[Return to Bookshelf]](BOOKSHELF.GIF) 
![[Contents]](TOC.GIF) 
![[Previous Section]](PREV.GIF) 
![[Next Section]](NEXT.GIF) 
![[Index]](INDEX.GIF) 
![[Help]](HELP.GIF) 
Termination occurs when a thread returns from its start_
routine function or calls pthread_exit. In the case of a
termination, the following actions are performed:
   - The return value of the start routine function is copied
   into the thread object. This value can be obtained when another
   thread later calls the pthread_join routine. If the start routine
   returns normally and is a procedure that does not return a
   value, then the return value obtained by pthread_join will be
   unpredictable.
   
- In the pthread interface to DECthreads, each cleanup
   handler that has been declared by pthread_cleanup_push and not
   yet removed by pthread_cleanup_pop is called. The most recently
   pushed handler is called first. Thread exit is accomplished by
   raising the exception pthread_exit_e. Using CATCH handlers in
   place of pthread_cleanup_push has the same effect, but is not
   portable.
   
- Each thread-specific data destructor is removed from the
   list of destructors for this thread, and then is called. This
   step destroys all the thread-specific data associated with the
   current thread. See Section 2.5
   for more information on thread-specific data.
   
- Any thread currently waiting in a call to pthread_join for
   the terminating thread is awakened.
   
- The thread object is marked to indicate that it is no
   longer needed by the thread itself. A check is made to determine
   if the thread is detached. If so, then the thread object is
   deallocated. Otherwise, the thread object is retained until it
   is detached.