Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Snailclimb/JavaGuide
Browse files Browse the repository at this point in the history
  • Loading branch information
Snailclimb committed Dec 12, 2023
2 parents 974e54e + cb4ede0 commit 4c3196d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/java/concurrent/threadlocal.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private void resize() {

我们以`get(ThreadLocal1)`为例,通过`hash`计算后,正确的`slot`位置应该是 4,而`index=4`的槽位已经有了数据,且`key`值不等于`ThreadLocal1`,所以需要继续往后迭代查找。

迭代到`index=5`的数据时,此时`Entry.key=null`,触发一次探测式数据回收操作,执行`expungeStaleEntry()`方法,执行完后,`index 5,8`的数据都会被回收,而`index 6,7`的数据都会前移。`index 6,7`前移之后,继续从 `index=5` 往后迭代,于是就在 `index=5` 找到了`key`值相等的`Entry`数据,如下图所示:
迭代到`index=5`的数据时,此时`Entry.key=null`,触发一次探测式数据回收操作,执行`expungeStaleEntry()`方法,执行完后,`index 5,8`的数据都会被回收,而`index 6,7`的数据都会前移。`index 6,7`前移之后,继续从 `index=5` 往后迭代,于是就在 `index=6` 找到了`key`值相等的`Entry`数据,如下图所示:

![](./images/thread-local/28.png)

Expand Down

0 comments on commit 4c3196d

Please sign in to comment.