ThreadLocal & ThreadPool
Reference: JavaGuide
ThreadLocal
The Thread class has a variable threadLocals, which can be considered a HashMap used to store thread-private content.
| |
The ThreadLocal class has an instance method set, which actually stores the content in threadLocals. The key is the ThreadLocal object itself.
The value of a variable in the Cache may be inconsistent with the value in Main Memory, leading to calculation errors.