Java examples for java.util:Collection Creation
Create synchronized Map
//package com.java2s; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] argv) { System.out.println(synchronizedMap()); }// w ww . j ava 2 s. c om public static <K, V> Map<K, V> synchronizedMap() { return Collections.synchronizedMap(new HashMap<K, V>()); } public static <K, V> Map<K, V> synchronizedMap(final int initialCapacity) { return Collections.synchronizedMap(new HashMap<K, V>( initialCapacity)); } protected static <K, V> Map<K, V> synchronizedMap( final int initialCapacity, final float loadFactor) { return Collections.synchronizedMap(new HashMap<K, V>( initialCapacity, loadFactor)); } }