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