Setting a value in Thread Local:
//Class A holds the static ThreadLocal variable.
Class A{
public static ThreadLocal myThreadLocal = new T
I study the java source code,
java.lang.Thread Class contains a instance variable as below.
ThreadLocal.ThreadLocalMap threadLocals = null;
Because threadLocals variable is non-static, Every thread in a application (i.e., every instance of Thread Class) will have it's own copy of threadLocals map.
Key for this map is, current ThreadLocal instance, and value is the value which you pass as argument to ThreadLocal.set().
When you try to fetch value as ThreadLocal.get() , internally, it will fetch from the ThreadLocalMap of Current Thread.
In simple terms, you are getting & setting values from/to your current Thread Object, not from/to your ThreadLocal object.