K
- 键类型V
- 值类型public class SafeConcurrentHashMap<K,V> extends ConcurrentHashMap<K,V>
ConcurrentHashMap.computeIfAbsent(Object, Function)
可能造成的死循环问题。相关bug见:@see https://bugs.openjdk.java.net/browse/JDK-8161372
ConcurrentHashMap.KeySetView<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
SafeConcurrentHashMap()
构造,默认初始大小(16)
|
SafeConcurrentHashMap(int initialCapacity)
构造
|
SafeConcurrentHashMap(int initialCapacity,
float loadFactor)
构造
|
SafeConcurrentHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
构造
|
SafeConcurrentHashMap(Map<? extends K,? extends V> m)
构造
|
Modifier and Type | Method and Description |
---|---|
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction) |
clear, compute, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
clone
public SafeConcurrentHashMap()
public SafeConcurrentHashMap(int initialCapacity)
initialCapacity
- 预估初始大小public SafeConcurrentHashMap(Map<? extends K,? extends V> m)
m
- 初始键值对public SafeConcurrentHashMap(int initialCapacity, float loadFactor)
initialCapacity
- 初始容量loadFactor
- 增长系数public SafeConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
initialCapacity
- 初始容量loadFactor
- 增长系数concurrencyLevel
- 并发级别,即Segment的个数public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
computeIfAbsent
in interface ConcurrentMap<K,V>
computeIfAbsent
in interface Map<K,V>
computeIfAbsent
in class ConcurrentHashMap<K,V>
Copyright © 2024. All rights reserved.