OSF DCE Application Development Guide--Core Components
Thread Concepts and Operations
• An error occurs in the thread.
Examples of errors that cause thread termination are programming errors,
segmentation faults, or unhandled exceptions.
7.1.3 Waiting for a Thread to Terminate
A thread waits for the termination of another thread by calling the pthread_join( )
routine. Execution in the current thread is suspended until the specified thread
terminates. If multiple threads call this routine and specify the same thread, all threads
resume execution when the specified thread terminates.
If you specify the current thread with the pthread_join() routine, a deadlock results.
Do not confuse pthread_join( ) with other routines that cause waits and that are related
to the use of a particular multithreading feature. For example, use pthread_cond_wait( )
or pthread_cond_timedwait( ) to wait for a condition variable to be signaled or
broadcast.
7.1.4 Deleting a Thread
A thread is automatically deleted after it terminates; that is, no explicit deletion
operation is required. Use pthread_detach() to free the storage of a terminated thread.
Use pthread_cancel() to request that a running thread terminate itself.
If the thread has not yet terminated, the pthread_detach( ) routine marks the thread for
deletion, and its storage is reclaimed immediately when the thread terminates. A thread
cannot be joined or canceled after the pthread_detach( ) routine is called for the thread,
even if the thread has not yet terminated.
If a thread that is not detached terminates, its storage remains so that other threads can
join with it. Storage is reclaimed when the thread is eventually detached.
7.2 New Primitives
Routines implemented by DCE Threads that are not specified by Draft 4 of the POSIX
1003.4a standard are indicated by an _np suffix to the name. These routines have not
been incorporated into the POSIX standard, and as such are extensions to that document.
The routines are fully portable.
124245 Tandem Computers Incorporated 7−3