pthread1, Introduction2, Threading Concepts3, indicating that the process ID is represented using the pid_t data type, and the thread ID is represented by the pthread_t data type. #include<pthread.h>intPthread_equal (pthread_t tid1, pthread_t Tid2);//used to compare two thread IDs for equalitypthread_t pthread_self (void);//the thread ID used by the thread to get itselfThe pthread_self function can be used with the Pthread_equal function when the thread needs to identify the data structure marked with the thread ID. For example, the main thread might put a work task in a queue and use the thread ID to control which jobs (P289-APUE) are processed by each worker thread. The main thread puts the new job into a work queue, and the thread pool of three threads moves out of the queue, each of which does not arbitrarily handle the job taken out of the top of the queue, but instead is assigned by the main thread program-controlled production, where the main thread puts the threading ID of the processing change job in the structure of each pending job. Each worker thread can only move out of a job labeled with its own thread ID. 4, thread creation # include<pthread.h>intPthread_create (pthread_t *restrict TIDP, const pthread_attr_t*restrict attr, void* (*START_RTN) (void), void *restrict arg);//Creating Threadssuccessful return 0, otherwise error encoding when Pthread_create is created successfully, the memory unit pointed to by TIDP is set to the thread ID of the newly created thread. The attr parameter is used to customize various thread properties. Now set to null the newly created thread runs from the START_RTN function, which has only one untyped pointer parameter arg, and if more than one parameter is required to pass to start_rnt, these parameters need to be placed in a struct, The address of this structure is then passed as an arg parameter to the example: Pthread_1.CPP
11th Chapter: Threading