Advanced Linux Programming note

Source: Internet
Author: User

1.pthread_create function creates thread that share the same memory with the process.

2.pthread_join function wait for threads until they stop

3.The pthread_self function returns the thread ID of the thread in which it is
called; This thread ID is compared with another thread ID using the
pthread_equal function

1 if (! pthread_equal (Pthread_self (), other_thread)) 2 pthread_join (Other_thread, NULL);

4.one of thread ' s important attribute is the detach State,which includes joinable State (default) and detached thread.t He difference is, the joinable thread is not automatically cleaned up by Gnu/linux when it terminates,but needs Pthread_join to does the clean up. A detached thread is just the opposite.

Even if a thread is created in a joinable state, the It may later being turned into a detached thread. To does this, call Pthread_detach. Once a thread is detached, it cannot be made joinable again.

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.