File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 56
56
57
57
- HashMap:基于哈希表实现。
58
58
59
- - HashTable :和 HashMap 类似,但它是线程安全的,这意味着同一时刻多个线程可以同时写入 HashTable 并且不会导致数据不一致。它是遗留类,不应该去使用它。现在可以使用 ConcurrentHashMap 来支持线程安全,并且 ConcurrentHashMap 的效率会更高,因为 ConcurrentHashMap 引入了分段锁。
59
+ - Hashtable :和 HashMap 类似,但它是线程安全的,这意味着同一时刻多个线程可以同时写入 Hashtable 并且不会导致数据不一致。它是遗留类,不应该去使用它。现在可以使用 ConcurrentHashMap 来支持线程安全,并且 ConcurrentHashMap 的效率会更高,因为 ConcurrentHashMap 引入了分段锁。
60
60
61
61
- LinkedHashMap:使用双向链表来维护元素的顺序,顺序为插入顺序或者最近最少使用(LRU)顺序。
62
62
@@ -810,9 +810,9 @@ static final int tableSizeFor(int cap) {
810
810
811
811
从 JDK 1.8 开始,一个桶存储的链表长度大于等于 8 时会将链表转换为红黑树。
812
812
813
- ### 9. 与 HashTable 的比较
813
+ ### 9. 与 Hashtable 的比较
814
814
815
- - HashTable 使用 synchronized 来进行同步。
815
+ - Hashtable 使用 synchronized 来进行同步。
816
816
- HashMap 可以插入键为 null 的 Entry。
817
817
- HashMap 的迭代器是 fail-fast 迭代器。
818
818
- HashMap 不能保证随着时间的推移 Map 中的元素次序是不变的。
You can’t perform that action at this time.
0 commit comments