作者的类注释:
This class provides thread-local variables. These variables differ from * their normal counterparts in that each thread that accesses one (via its * {@code get} or {@code set} method) has its own, independently initialized * copy of the variable. {@code ThreadLocal} instances are typically private * static fields in classes that wish to associate state with a thread (e.g., * a user ID or Transaction ID).
此类提供线程本地变量。这些变量和每一个线程中通过 {@code get} or {@code set} method)访问的普通变量不同,它们都有自己独立初始化的变量副本。
此类是线程安全的,应用很多。
1、按照几个关键类变量作图如下:
2、理解实现原理、好处
应对其带来的问题,如内存泄漏问题,解决方法