Thread local storage

The API function TlsAlloc allocates one 32-bit value for each thread in the process, and initialises each value to NULL. The value is identified by a DWORD index – more than one value can be allocated. Any thread can access its own 32-bit value using the TlsGetValue and TlsSetValue functions. Typically, the value is used as a pointer to a dynamically allocated structure containing information specific to each thread.