Changes the detachstate attribute in the specified thread attributes object.
pthread_attr_setdetachstate( attr, detachstate);
Argument Data Type Accessattr opaque pthread_attr_t write detachstate integer read
#includeint pthread_attr_setdetachstate ( pthread_attr_t *attr, int detachstate);
PTHREAD_CREATE_JOINABLE This is the default value. Threads are created in "undetached" state. PTHREAD_CREATE_DETACHED The created thread is detached immediately, before it begins running.
You cannot use the thread handle (the value of type pthread_t that is returned by pthread_create) for a detached thread. This means that you cannot cancel the thread with pthread_cancel. You also cannot use pthread_join to wait for the thread to complete or to retrieve the thread's return status.
When a thread that has not been detached completes execution, DECthreads will retain the state of that thread to allow another thread to join with it. If the thread is detached before it completes, DECthreads is free to immediately reclaim the thread's storage and resources. Failing to detach threads that have completed execution can result in wasting resources, so threads should be detached as soon as the program is done with them. If there is no need to use the thread's handle after creation, create the thread initially detached.
Return Description0 Successful completion. [EINVAL] The value specified by the detachstate argument is invalid.
pthread_attr_init pthread_attr_getdetachstate pthread_create pthread_join