Use thr_self(3T) to get the ID of the calling thread. (For POSIX threads, see "pthread_self(3T)".)
#include <thread.h> thread_t thr_self(void);