ThreadLocal笔记

发布时间:2022-06-28 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了ThreadLocal笔记脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
 1 static class ThreadLocalMap {
 2 ...
 3  * The table, resized as necessary.
 4          * table.length MUST always be a power of two.
 5          */
 6         private Entry[] table;
 7 
 8         /**
 9          * The number of entries in the table.
10          */
11         private int size = 0;
12 
13         /**
14          * The next size value at which to resize.
15          */
16         private int threshold; // Default to 0
17 
18         /**
19          * Set the resize threshold to maintain at worst a 2/3 load factor.
20          */
21         private void setThreshold(int len) {
22             threshold = len * 2 / 3;
23         }
24 ...
25 }

这个  private int threshold;  属性意思是ThreadLocalMap内的Entry[]数组最大数据项 项数的意思。由于 《Java数据结构和算法中文版 -- 第二版》 第11 章 哈希表 : 

  •  P415 聚集 
  • 数组填得越满,聚集越可能发生。数组有一半数据项时,这通常不是问题,当三分之二满的时候,情况也不会太坏。 然而,如果超过这个界限,随着聚集越来越严重,性能下降也很严重。因此,设计哈希表的关键是确保它不会超过整个数组容量的一半最多到三分之二(在本章最后将讨论哈希表的装填数据的程度和探测长度的数学关系。)
  • 装填因子(表中数据项数/表长)

 

脚本宝典总结

以上是脚本宝典为你收集整理的ThreadLocal笔记全部内容,希望文章能够帮你解决ThreadLocal笔记所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: