Create new Concurrent Hash Map - Java java.util

Java examples for java.util:Collection Creation

Description

Create new Concurrent Hash Map

Demo Code


//package com.java2s;

import java.util.Map;

import java.util.concurrent.ConcurrentHashMap;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newConcurrentHashMap());
    }//  w  w  w .  j  a va  2  s.c o  m

    public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap() {
        return new ConcurrentHashMap<K, V>();
    }

    public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap(
            final int initialCapacity) {
        return new ConcurrentHashMap<K, V>(initialCapacity);
    }

    public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap(
            final int initialCapacity, final float loadFactor,
            final int concurrencyLevel) {
        return new ConcurrentHashMap<K, V>(initialCapacity, loadFactor,
                concurrencyLevel);
    }

    public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap(
            final Map<? extends K, ? extends V> m) {
        return new ConcurrentHashMap<K, V>(m);
    }
}

Related Tutorials