Example usage for java.util Collections synchronizedMap

List of usage examples for java.util Collections synchronizedMap

Introduction

In this page you can find the example usage for java.util Collections synchronizedMap.

Prototype

public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m) 

Source Link

Document

Returns a synchronized (thread-safe) map backed by the specified map.

Usage

From source file:Main.java

public static <K, V> Map<K, V> synchronizedHashMap() {
    return Collections.synchronizedMap(new HashMap<K, V>());
}

From source file:Main.java

public static <K, V> Map<K, V> newSyncronizedHashMap() {
    return Collections.synchronizedMap(new HashMap<>());
}

From source file:Main.java

public static <K, V> Map<K, V> synchronizedMap() {
    return Collections.synchronizedMap(new HashMap<K, V>());
}

From source file:Main.java

public static <K, V> Map<K, V> synchronizedMap(final int initialCapacity) {
    return Collections.synchronizedMap(new HashMap<K, V>(initialCapacity));
}

From source file:Main.java

public static <K, V> Map<K, V> newSynchronizedTreeMap() {
    final TreeMap<K, V> treeMap = newTreeMap();
    return Collections.synchronizedMap(treeMap);
}

From source file:Main.java

protected static <K, V> Map<K, V> synchronizedMap(final int initialCapacity, final float loadFactor) {
    return Collections.synchronizedMap(new HashMap<K, V>(initialCapacity, loadFactor));
}

From source file:Main.java

public static <K extends Object, V extends Object> Map<K, V> synchronizedMap(final Map<K, V> map) {
    return Collections.synchronizedMap(map);
}

From source file:org.openmrs.web.user.CurrentUsers.java

/**
 * Initialize the current users list.//w w  w. j a v  a 2  s. com
 * 
 * @param servletContext
 */
public static Map<String, String> init(ServletContext servletContext) {
    Map<String, String> currentUserMap = Collections.synchronizedMap(new TreeMap<String, String>());
    servletContext.setAttribute(WebConstants.CURRENT_USERS, currentUserMap);
    return currentUserMap;
}

From source file:Main.java

public static <K, V> Map<K, V> synchronizedMap() {
    return Collections.synchronizedMap(Maps.<K, V>newHashMap());
}

From source file:Main.java

public static <K, V> Map<K, V> synchronizedMap(int initialCapacity) {
    return Collections.synchronizedMap(new HashMap<K, V>(initialCapacity));
}