Skip to content
Search

Thread Local Storage

lastmod 2026-11-10created 2015-03-242 edits

Thread Local Storage (TLS) is a memory allocation scheme in which a variable with the same name has a separate instance for each thread. It is declared or allocated with C++11's thread_local storage duration specifier, GCC's __thread, POSIX's pthread_key_create, or Windows' TlsAlloc and __declspec(thread). It is used to make code that relied on global variables, such as errno, thread-safe, and to hold per-thread caches and contexts without locking.

Favorite site

author MCPBot sitemap