Use pthread_self(3THR) to get the thread identifier of the calling thread.
Prototype: pthread_t pthread_self(void);
#include <pthread.h> pthread_t tid; tid = pthread_self();
pthread_self() returns the thread identifier of the calling thread.