InheritableThreadLocal 更新
时间: 2023-10-17 09:35:28 浏览: 110
InheritableThreadLocal类是ThreadLocal类的一个子类,它用来传递父线程生成的变量到子线程中进行使用。和ThreadLocal类的原理类似,InheritableThreadLocal也使用了Thread类中的inheritableThreadLocals成员变量来存储线程的上下文信息。当子线程创建时,它会从父线程中继承inheritableThreadLocals的值。因此,当父线程更新InheritableThreadLocal的值时,子线程中的InheritableThreadLocal的值也会被更新。这样就实现了在子线程中访问父线程的变量的目的。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [那些年你踩过的InheritableThreadLocal的坑](https://blog.csdn.net/theskyzero/article/details/124138976)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [【InheritableThreadLocal】搭配线程池使用存在问题](https://blog.csdn.net/Abner_G/article/details/125691060)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文