The global lock cache feeds the per-thread lock caches.
全局锁缓存将其内容提供给单线程锁缓存。
Using ThreadLocal makes sense when you need to store variable instances on a per-thread basis.
当您需要以线程为单位存储变量实例时,使用 ThreadLocal 很有意义。
Also, because the references to the per-thread values are stored in the owning thread object, when the thread gets garbage collected, so can its per-thread values.
而且,因为每线程值的引用被存储在自已的Thread对象中,所以当对Thread进行垃圾回收时,也能对该Thread的每线程值进行垃圾回收。
应用推荐