集册 Java实例教程 创建并发哈希映射

创建并发哈希映射

欢马劈雪     最近更新时间:2020-01-02 10:19:05

454
创建并发哈希映射


//package com.nowjava;

import java.util.*;/* 来自 n o w    j a v a  . c o m*/

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));

    }


    public static int getSize(int size) {

        return getSize(size, true);

    }
//nowjava - 时  代  Java

    public static int getSize(int size, boolean useMinimum) {

        
展开阅读全文