Java examples for Collection Framework:Map
create Concurrent Hash Map
//package com.java2s; import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class Main { public static final double FACTOR = 0.75; public static final int MIN_CAPACITY = 16; public static <K, V> Map<K, V> createConcurrentHashMap(int size) { return new ConcurrentHashMap<>(getSize(size)); }// w ww. j a v a 2s . c o m public static int getSize(int size) { return getSize(size, true); } public static int getSize(int size, boolean useMinimum) { int s = (int) (size / FACTOR) + 1; if (useMinimum) { s = Math.max(MIN_CAPACITY, s); } return s; } }