The pthread_key_create function create a new key that is visible to all threads. This key can be used with pthread_setspecific and pthread_getspecific to save and retrieve data associated with the a thread. If the function destructor is not NULL, then when a thread terminates, the destructor function will be called with the value associated with the key as the argument.