Once a detached thread has terminated, its resources, including the thread ID, may be reused

Source: Internet
Author: User
Tags terminates

Pthread_detach ()-mark a thread as detached to reclaim its resources when it terminates

Synopsis

# Include <Pthread. h>

Int pthread_detach ( Pthread_t thread );

Parameters
Thread

Thread whose resources are to be reclaimed immediately when it terminates.

 

Description

Pthread_detach ()Is used to detach the threadThread. WhenThreadTerminates, its resources will automatically be reclaimed by the system. IfThreadHas already terminated,Pthread_detach ()Causes the resourcesThreadTo be reclaimed by the system.

Pthread_detach ()Does not causeThreadTo terminate.

Once a detached thread has terminated, its resources, including the thread ID, may be reused by the system. The return status of a detached thread is lost when the thread terminates.

Calling this function multiple times for the same thread results in undefined behavior.

Return Value

Upon successful completion,Pthread_detach ()Returns zero. Otherwise, an error number is returned to indicate the error (ErrnoVariable is not set ).

Errors

If any of the following occur,Pthread_detach ()Function returns the corresponding error number:

[Einval]

ThreadDoes not refer to a joinable thread.

[Esrch]

No thread cocould be found correspondingThread.

 

Author

Pthread_detach ()Was derived from the ieee posix p1003.1c standard.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.