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) {
Experience pair programming with AI  Get Codota for Java