Back to Developer Roadmap

Thread Local Storage

src/data/roadmaps/server-side-game-developer/content/[email protected]

4.0577 B
Original Source

Thread Local Storage

Thread Local Storage (TLS) is a mechanism by which variables are allocated such that each thread gets its own individually allocated variable, but the name of the variable is the same in each thread. In other words, the same variable can simultaneously hold different values for different threads. TLS is required when you need to use a global or static variable in a thread-safe manner but the data must be unique to each thread. TLS can be used in many applications, but it is particularly useful for storing per-thread state in server applications.