Converts a joinable thread to a detached (non-joinable) thread.
#include <pthread.h>
int pthread_detach (
pthread_t thread);
(IN) Specifies the ID of the thread to convert to a detached thread.
If successful, returns 0; otherwise, returns a nonzero error code:
If successful, pthread_detach converts the joinable thread specified by the thread parameter to a detached thread. Such a thread can no longer be joined using the pthread_join function.
If a thread has already called pthread_join for the thread being detached, the thread returns from pthread_join with an error indicating that the thread being joined was not joinable.If the thread being detached has already exited and is waiting for a join operation, it will be cleaned up immediately. The thread cannot be subsequently joined using pthread_join.
The pthread_detach function can be called by a thread for itself, but thread ID has to be derived by calling pthread_self.