List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap
public ConcurrentHashMap(int initialCapacity, float loadFactor)
From source file:Main.java
public static <K, V> ConcurrentMap<K, V> createConcurrentMap(int initialCapacity, float loadFactor) { return new ConcurrentHashMap<K, V>(initialCapacity, loadFactor); }
From source file:Main.java
/** * Create a properly sized {@link ConcurrentHashMap} based on the given expected number of elements and an * explicit load factor//from w w w. j a v a 2s. c om * * @param expectedNumberOfElements The expected number of elements for the created map * @param loadFactor The collection load factor * @param <K> The map key type * @param <V> The map value type * * @return The created map. */ public static <K, V> ConcurrentHashMap<K, V> concurrentMap(int expectedNumberOfElements, float loadFactor) { final int size = expectedNumberOfElements + 1 + (int) (expectedNumberOfElements * loadFactor); return new ConcurrentHashMap<K, V>(size, loadFactor); }