1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-20 22:17:09 +08:00

[refractor] update threadlocal

This commit is contained in:
guide 2020-07-31 17:13:02 +08:00
parent 449dda4857
commit 3c2d4ab28e
4 changed files with 10 additions and 4 deletions

View File

@ -34,17 +34,23 @@
<tr>
<td align="center" valign="middle">
<a href="https://mp.weixin.qq.com/s/li9_YXNVxan6Qgt3Q9FYqA">
<img src="https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-7/WechatIMG1.png" style="margin: 0 auto;width:400px" /></a>
<img src="https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-7/WechatIMG1.png" style="margin: 0 auto;width:450px" /></a>
</td>
<td align="center" valign="middle">
<a href="https://mp.weixin.qq.com/s/uXgGt66Df3JC4GM7d0LlZg" target="_blank">
<img src="https://imgkr.cn-bj.ufileos.com/75fef802-16f0-4e0b-9d6f-a9173f24a40f.png" style="margin: 0 auto;width:400px" /></a>
<img src="https://imgkr.cn-bj.ufileos.com/75fef802-16f0-4e0b-9d6f-a9173f24a40f.png" style="margin: 0 auto;width:450px" /></a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://faxian.lagou.com/discover/05a25f7c41404735b01b7f2a61bcf833.html?ver=2">
<img src="https://imgkr2.cn-bj.ufileos.com/46974d4c-3f5c-415b-a59c-c11475bd502a.png?UCloudPublicKey=TOKEN_8d8b72be-579a-4e83-bfd0-5f6ce1546f13&Signature=iFLlYkAWJPv7MOAO2sLADT4vRbM%253D&Expires=1596273069" style="margin: 0 auto;width:450px" /></a>
</tr>
</tbody>
</table>
## 目录
- [Java](#java)

View File

@ -338,11 +338,11 @@ ThreadLocalMap(ThreadLocal<?> firstKey, Object firstValue) {
比如我们在同一个线程中声明了两个 `ThreadLocal` 对象的话,会使用 `Thread`内部都是使用仅有那个`ThreadLocalMap` 存放数据的,`ThreadLocalMap`的 key 就是 `ThreadLocal`对象value 就是 `ThreadLocal` 对象调用`set`方法设置的值。
![ThreadLocal数据结构](https://upload-images.jianshu.io/upload_images/7432604-ad2ff581127ba8cc.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/806)
![ThreadLocal数据结构](images/threadlocal数据结构.png)
`ThreadLocalMap``ThreadLocal`的静态内部类。
![ThreadLocal内部类](https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-6/ThreadLocal内部类.png)
![ThreadLocal内部类](images/ThreadLocal内部类.png)
### 3.4. ThreadLocal 内存泄露问题

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB