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)