pthread_self()
函数将给出当前线程的线程ID。
pthread_t pthread_self(void);
该pthread_self()
函数返回调用线程的Pthread句柄。pthread_self()函数不会返回调用线程的整数线程。您必须使用pthread_getthreadid_np()
返回该线程的整数标识符。
注意:
pthread_id_np_t tid;
tid = pthread_getthreadid_np();
比这些调用快得多,但是提供了相同的行为。
pthread_id_np_t tid;
pthread_t self;
self = pthread_self();
pthread_getunique_np(&self, &tid);