Linux The default pthread_create is owned by the caller responsible for the resource recycling of the child thread
When the parent thread exits, the child thread also exits, so the parent thread is pushed out to call the Pthread_join function to block waiting for the child thread to exit
Pthread_detach (TID) keeps thread Tid's thread in a detached state, the thread is in a detached state, the resource is reclaimed when the thread terminates, otherwise the terminating child thread consumes system resources until the parent thread calls Pthread_join
1 Parent line enters upgradeable and child thread termination
At this time
If a child thread is nearly detached from the parent thread, such as calling Pthread_datach, the resource is recycled
If there is no separation, the resource cannot be freed
1 Sub-line enters upgradeable with parent thread termination
At this time
If a child thread calls a thread-detach function Pthread_detach, or the parent thread calls the Pthread_join, the resource is freed
Resource cannot be freed if none of the above two are called
Linux pthread pthread_create pthread_join Pthread_detach