Java 异步获取ThreadLocal中的数据
时间: 2023-08-27 09:13:43 浏览: 110
要在子线程中异步获取父线程中的ThreadLocal中的数据,可以使用InheritableThreadLocal类。InheritableThreadLocal与ThreadLocal类似,但区别在于它允许子线程访问父线程的ThreadLocal副本,即在子线程中可以获取到父线程中的ThreadLocal副本的值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [多线程 - 子线程中获取父线程的 `ThreadLocal` 中的值、`ThreadLocal` 的数据结构](https://blog.csdn.net/qq_43116031/article/details/129924053)[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中的信息](https://blog.csdn.net/yeluowan/article/details/127107481)[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 ]
阅读全文