thr_keycreate(3THR) allocates a key that is used to identify thread-specific data in a process. (For POSIX threads, see pthread_key_create(3THR).)
#include <thread.h> int thr_keycreate(thread_key_t *keyp, void (*destructor) (void *value));