这就是我想知道的:
如果我使用 pthread_create() 创建一个线程,然后从该线程调用 pthread_self(),该值是否与我在主线程中传递给 pthread_create 的 pthread_t 值匹配?
//pthread_t variable
pthread_t producer_thread = (pthread_t*)malloc(sizeof(pthread_t));;
//create the thread
pthread_create(producer_thread, NULL, producer, NULL);
printf("Pthread_t variable after creating thread says %d\n", producer_thread);
....
//function passed to thread
void producer(void *p){
printf("Pthread self says: %d\n", pthread_self());
}