Detached vs. Joinable POSIX threads

  1. Create a detached thread when you know you won’t want to wait for it with pthread_join(). The only performance benefit is that when a detached thread terminates, its resources can be released immediately instead of having to wait for the thread to be joined before the resources can be released.

  2. It is ‘legal’ not to join a joinable thread; but it is not usually advisable because (as previously noted) the resources won’t be released until the thread is joined, so they’ll remain tied up indefinitely (until the program exits) if you don’t join it.

Leave a Comment