The Threadlocal class is designed to solve multi-threaded security issues. Thread safety means that each thread operates its own variables and does not affect the values of other threads.
In many cases, threadlocal is easier and more convenient than using the synchronized synchronization mechanism to solve thread safety problems, and results programs have higher concurrency.
1 threadlocal The idea of solving multithreading security is to control it through Threadlocalmap, just like there are multiple key-value pairs in a map, Threadlocalmap can be understood by comparing the map.
2 generally by overwriting Threadlocal's InitialValue () method on the line set
3 threadlocal Since the JDK1.2 began to appear, since 1.5 began to support generics.
Specific understanding, you can learn from the following blog, written in very detailed:
http://blog.csdn.net/lufeng20/article/details/24314381
November 26, 2015 Java Basic Series (iii) Threadlocal class primary Learning