Sometimes it’s helpful to associate data with an instance of an object. For example, window extra bytes associate data with a specific window by using the
SetWindowLong functions. You can use Thread Local Storage (TLS) to associate data with a specific thread of execution. For example, you can associate the creation time of a thread with a thread. Then, when the thread terminates, you can determine the thread’s lifetime.
The C/C++ run-time library uses TLS. Because the library was designed years before multithreaded applications, most functions in the library are intended for use with single-threaded applications. The
_tcstok_s function is an excellent example. ...