ThreadLocal和InheritableThreadLocal
时间: 2023-08-26 19:18:39 浏览: 118
ThreadLocal和InheritableThreadLocal是用于在多线程环境下存储线程局部变量的工具类。它们的本质是通过ThreadLocalMap对象来存储数据。具体来说,ThreadLocalMap的key对象是ThreadLocal,value则是实际需要存储的业务对象。在Thread类中,有两个变量分别持有ThreadLocalMap对象,即threadLocals和inheritableThreadLocals。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [ThreadLocal,InheritableThreadLocal,TransmittableThreadLocal](https://blog.csdn.net/u012060033/article/details/104980889)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [ThreadLocal和InheritableThreadLocal](https://blog.csdn.net/weixin_44991304/article/details/116300781)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文