All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mutabilitydetector.benchmarks.ImmutablePossiblyThreadsafeClass Maven / Gradle / Ivy

There is a newer version: 0.10.6
Show newest version
package org.mutabilitydetector.benchmarks;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

/**
 * From StackOverflow question.
 * http://stackoverflow.com/questions/5635032/is-this-class-threadsafe
 */
public class ImmutablePossiblyThreadsafeClass {

    private final Map map;

    public ImmutablePossiblyThreadsafeClass(final Map map) {
        this.map = new HashMap();

        for (Entry entry : map.entrySet()) {
            this.map.put(entry.getKey(), entry.getValue());
        }
    }

    public V get(K key) {
        return this.map.get(key);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy