Code example for ReentrantReadWriteLock

Methods: readLockwriteLock

 * @param <K> type of keys 
 * @param <V> type of values 
public class ParallelMap<K, V> { 
    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    private final Lock readLock = lock.readLock();
    private final Lock writeLock = lock.writeLock();
    private final Map<K, V> map;
    public ParallelMap() { 
        this(new HashMap<K, V>());
     * For testing purpose: to inject manipulated map. 
    protected ParallelMap(Map<K, V> map) {
Contextual code suggestions in your IDE  Get Codota for Java