pthread_keys is what you said is the local thread store referenced by the shared key. Thus, multiple threads use the same key, but receive different storage space (in the stream).
A quick example (far-fetched too), they say that you built an asynchronous server (for example, IMAP). You can track client connections in the array, each of which has a key for the current task / request. Therefore, when a request arrives in a new stream, it is created, and the stream stores a pointer to the request structure in Client_Connection-> WhatAmIDoing key. Now the thread should not go around this pointer, because any function executed by this thread can simply call the pthread_getspecific () function and get a pointer to what it should do.
Chris s
source share