C + + multithreaded Learning

Source: Internet
Author: User

Linux thread execution differs from windows in thatPthread has two state joinable states and Unjoinable states

The default state of a thread is joinable, and if the thread is joinable state, the thread takes up the stack and the thread descriptor (a total of more than 8K) when the thread function returns to exit or Pthread_exit. These resources will be released only if you call Pthread_join.
These resources are automatically freed when the thread function exits or pthread_exit, if the threads are in a unjoinable state.

The Unjoinable property can be specified at pthread_create time, or Pthread_detach itself in the thread after the thread is created, such as: Pthread_detach (Pthread_self ()), Change the status to Unjoinable state to ensure the release of the resource. If the thread state is joinable, you need to call Pthread_join at a later time.

C + + multithreaded Learning

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.