pthread_join

Waits for a thread to terminate.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h>
   
  int   pthread_join (
     pthread_t   thread,
     void      **status);
  

Parameters

thread

(IN) Specifies the thread to wait for.

status

(OUT) Points to the location where the application-defined status of the terminated thread is returned. This can be NULL.

Return Values

If successful, returns 0. Otherwise, returns a nonzero error code:

Decimal

Constant

Description

9

EINVAL

The thread parameter does not specify a joinable thread.

15

EDEADLK

A deadlock was detected or the thread parameter specifies the calling thread.

77

ERSCH

No thread was found that corresponded to the thread ID.

Remarks

Only joinable application threads can be joined by calling pthread_join. When a joinable thread exits and a thread is not already waiting to join the exiting thread, the system maintains sufficient state to support subsequent calls to pthread_join. If you do not call pthread_join on an exited joinable thread, system resources are held up unnecessarily.

See Also