6.30 notes

Source: Internet
Author: User

1. Detach and Join Problems

Detach indicates that the system automatically recycles the thread after it ends. The master process is no longer in charge. Join indicates that the main process waits until the thread ends. A thread must be pthread_join or pthread_detach; otherwise, memory leakage occurs. If you want to create a thread that does not need to be managed, after pthread_attr_setdetachstate (atrr, pthread_create_detachable) is created, you do not need to worry about pthread_create_joinable. The parent process needs to wait for 2. pthread_key_t thread private data, threads are mutually non-interfering pthread_key_t keypthread_key_create (& Key, null) threads can use pthread_key_setspecific pthread_key_getspecific to complete the settings and obtain the following information: key is obviously a feature of every thread, such as errno. In fact, errno is designed in this way. 3. Once the thread is forced to execute once to ensure initialization, or a specific action will only be executed once. (For example, initialization of a single instance) pthread_once_t once = pthread_once_init pthread_once (once, once_func)

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.