Java tutorial
//package com.java2s; /* * Copyright (C) 2013 * * 52North Initiative for Geospatial Open Source Software GmbH * Contact: Andreas Wytzisk * Martin-Luther-King-Weg 24 * 48155 Muenster, Germany * info@52north.org * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Main { 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)); } }