Both are completely unrelated.
两者是完全没有关系的。
The ThreadLocal class stores a variable in the Thread object of the current running thread, each thread gets its own copy of ThreadLocal instance, the ThreadLocal instances are not shared among the Threads.
ThreadLocal 类在当前正在运行的线程的Thread对象中存储一个变量,每个线程获得它自己的ThreadLocal实例副本,ThreadLocal实例不在线程之间共享。
Volatile keyword instructs the compiler that this variable be accessed/shared across multiple threads.
volatile 指示编译器认为该变量可以跨多个线程访问 / 共享。