Operations | Monitoring | ITSM | DevOps | Cloud

February 2018

An Introduction to Java's ThreadLocal Storage

As its name suggests, a single instance of ThreadLocal can store different values for each thread independently. Therefore, the value stored in a ThreadLocal instance is specific (local) to the current running thread. Any other code logic running on the same thread will see the same value, but not the values set on the same instance by other threads. There are exceptions, though, like InhertiableThreadLocal, which inherits parent threads’ values by default.