![]() |
CITS2002 Systems Programming |
← prev | next → | ![]() |
![]() |
|||
Joining and detaching POSIX threads"joining" is the simplest way to accomplish synchronization between threads. The pthread_join() function blocks the calling thread, perhaps just main(), until the specified threadID thread terminates.As with traditional Linux processes and the wait() system-call, we are waiting for the requested thread to terminate, and are able to receive termination information when it terminates.
When a thread is created, one of its attributes defines whether it is joinable or detached. Only joinable threads can be joined(!). If a thread is created as detached, it can never be joined. If we know in advance that a thread will never need to join with another thread, it is usually created in the detached state. Some system resources may be able to be freed.
CITS2002 Systems Programming, Lecture 20, p9, 9th October 2023.
|