Multithreaded Programming Guide

Get the Thread Identifier

pthread_self(3T)

Use pthread_self(3T) to get the ID of the calling thread.

Prototype:
pthread_t	 pthread_self(void);
#include <pthread.h>

pthread_t tid;

tid = pthread_self();

Return Values

Returns the ID of the calling thread.