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:delfos.rs.contentbased.vsm.booleanvsm.SparseVector.java

public SparseVector(Collection<Key> domain) {
    map = Collections.synchronizedMap(new HashMap<>());

    this.domain = Collections.synchronizedSet(domain.stream().collect(Collectors.toSet()));
}

From source file:org.amplafi.flow.impl.DefaultFlowValuesMap.java

public DefaultFlowValuesMap() {
    this.map = Collections.synchronizedMap(new LinkedHashMap<DefaultFlowValuesMapKey, String>());
}

From source file:com.sb.suites.dao.ServiceLocator.java

private ServiceLocator() throws ServiceLocatorException {
    try {//  ww w . j av  a 2 s. c om
        ic = new InitialContext();
        //ec = (Context) ic.lookup("java:/comp/env");
        cache = Collections.synchronizedMap(new HashMap<String, DataSource>());
    } catch (NamingException ne) {
        throw new ServiceLocatorException(ne);
    } catch (Exception e) {
        throw new ServiceLocatorException(e);
    }
}

From source file:ch.cyberduck.core.Cache.java

public Cache(int size) {
    if (size == Integer.MAX_VALUE) {
        // Unlimited
        impl = Collections.synchronizedMap(new LinkedHashMap<T, AttributedList<T>>());
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    } else if (size == 0) {
        impl = Collections.emptyMap();
        reverse = Collections.emptyMap();
    } else {/* ww  w.  j av a  2s .  co  m*/
        // Will inflate to the given size
        impl = Collections.synchronizedMap(new LRUMap<T, AttributedList<T>>(size));
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    }
}

From source file:com.memetix.translate.LRUCache.java

public LRUCache(int maxSize, boolean scanUntilRemovable) {
    map = Collections.synchronizedMap(new LRUMap<Object, Object>(maxSize, scanUntilRemovable));
}

From source file:fr.aliasource.index.solr.SolrClientFactory.java

public SolrClientFactory() {
    logger = LogFactory.getLog(getClass());
    servers = Collections.synchronizedMap(new HashMap<String, SelfOptimizingServer>());
}

From source file:com.relicum.ipsum.Configuration.RankMap.java

/**
 * Instantiates a new Rank map This is currently required even though all other methods are static.
 * Will be fixing this shortly./*from ww w . ja  v a  2  s  . c  om*/
 */
public RankMap() {

    rankMap = Collections.synchronizedMap(new EnumMap<>(GameRanks.class));
    rankMap.put(GameRanks.NOOB, DARK_GRAY);
    rankMap.put(GameRanks.VIP, GRAY);
    rankMap.put(GameRanks.MVP, AQUA);
    rankMap.put(GameRanks.HERO, GOLD);
    rankMap.put(GameRanks.MOD, LIGHT_PURPLE);
    rankMap.put(GameRanks.ADMIN, DARK_PURPLE);
    rankMap.put(GameRanks.DEV, BLUE);
    rankMap.put(GameRanks.OWNER, RED);

}

From source file:ch.cyberduck.core.AbstractCache.java

public AbstractCache(int size) {
    if (size == Integer.MAX_VALUE) {
        // Unlimited
        impl = Collections.synchronizedMap(new LinkedHashMap<T, AttributedList<T>>());
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    } else if (size == 0) {
        impl = Collections.emptyMap();
        reverse = Collections.emptyMap();
    } else {/*from   w  ww  . j  a  v  a2 s.  c  o  m*/
        // Will inflate to the given size
        impl = Collections.synchronizedMap(new LRUMap<T, AttributedList<T>>(size));
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    }
}

From source file:net.ontopia.persistence.proxy.QueryCache.java

QueryCache(DetachedQueryIF query, CacheIF cache, int lrusize) {
    this.query = query;
    this.cache = cache;
    this.lru = Collections.synchronizedMap(new LRUMap(lrusize));
    this.lrusize = lrusize;
}

From source file:org.mule.transport.jms.redelivery.CountingRedeliveryHandler.java

@SuppressWarnings("unchecked")
public CountingRedeliveryHandler() {
    super();
    messages = Collections.synchronizedMap(new LRUMap(256));
}