A thread’s resources are not immediately released at termination, unless
the thread was created with the detach state attribute set to
PTHREAD_CREATE_DETACHED, or if pthread_detach is called for
its pthread_t.
An undetached thread will remain terminated state until its identifier is passed to pthread_join or pthread_detach.
To sum it up, you have three options:
- create your thread with detached attribute set(PTHREAD_CREATE_DETACHED attribute)
- Detach your thread after creation (by calling
pthread_detach), or - Join with the terminated threads to recycle them (by calling
pthread_join).
Hth.