mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Update java-concurrent-questions-02.md
This commit is contained in:
parent
1841062c12
commit
703c7b4b75
@ -457,9 +457,12 @@ public class Thread implements Runnable {
|
||||
|
||||
```java
|
||||
public void set(T value) {
|
||||
//获取当前请求的线程
|
||||
Thread t = Thread.currentThread();
|
||||
//取出 Thread 类内部的 threadLocals 变量(哈希表结构)
|
||||
ThreadLocalMap map = getMap(t);
|
||||
if (map != null)
|
||||
// 将需要存储的值放入到这个哈希表中
|
||||
map.set(this, value);
|
||||
else
|
||||
createMap(t, value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user