ThreaLocal
时间: 2023-08-27 17:20:36 浏览: 172
ThreadLocal是一个用于实现线程数据隔离的类。每个线程访问ThreadLocal时,会产生一个属于该线程的局部变量副本。当线程结束时,ThreadLocal及变量会随着线程一起被回收。ThreadLocal本身并不存储值,它只是作为key存储在Thread对象中的ThreadLocalMap中,而value则是我们存储的变量。通过ThreadLocal的set方法,可以为每个线程单独保存线程变量数据。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ThreaLocal的简单使用](https://blog.csdn.net/weixin_48917089/article/details/126891255)[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%"]
- *2* *3* [【ThreadLocal详解】](https://blog.csdn.net/qq_44316957/article/details/127301227)[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 ]
阅读全文