Pthread_self() in C In this section, we'll explore the impact of pthread_self () on C programming language. To obtain the current thread's ID, developers leverage the pthread_self() function, which can differentiate between threads. However, if there are multiple threads threads and one of...
In main2, the process id is 9814 and thread id is 4151932608. 分析: 在main函数中调用sleep函数的原因。在Linux环境中,进程的本质就是含有一个线程的进程,其在创建线程之前就包含一个线程,因此此时有一个进程ID和一个线程ID(当然也有一个线程号),两个ID不想等,将此时的线程称为主控线程,后面创建的线程...
Therefore, variables of type pthread_t can't portably be compared using the C equality operator (==); use pthread_equal(3) instead. Thread identifiers should be considered opaque: any attempt to use a thread ID other than in pthreads calls is nonportable and can lead to unspecified ...