Code example for ReentrantReadWriteLock

Methods: readLock, writeLock

0
 * @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) {
        if (map == null) {