| Modifier and Type | Method and Description |
|---|---|
static int |
calculateInitialCapacity(int expectedSize)
This is a temporary workaround for Java 8 issue https://bugs.openjdk.org/browse/JDK-8186958.
|
static <K,V> V |
computeIfAbsent(Map<K,V> map,
K key,
Function<K,V> mappingFunction)
This is a temporary workaround for Java 8 specific performance issue https://bugs.openjdk.org/browse/JDK-8161372.
|
public static int calculateInitialCapacity(int expectedSize)
Calculate the initial capacity for the Map from the expected size and the default load factor
for the Map (0.75).
expectedSize - the expected sizeMappublic static <K,V> V computeIfAbsent(Map<K,V> map, K key, Function<K,V> mappingFunction)
ConcurrentHashMap.computeIfAbsent(k,v) locks when k is present. Add pre-screen before locking inside computeIfAbsent.
Note: This utility is not for a general purpose usage. Carefully consider the removal operations from the map. If you have many remove operations that are critical, do not use this pre-screening.
map - the ConcurrentHashMap instancekey - key with which the specified value is to be associatedmappingFunction - the function to compute a value