Java读写锁,ReadWriteLock.java接口, RentrantReadWriteLock.java实现.通过读写锁,可以实现读-读线程并发,读-写,写-读线程互斥进行.以前面试遇到一个问题,ConcurrentHashMap的实现原理,如何封装Map效率更高.今天看了<Java并发编程实战>,封装的ReadWriteMap类,效率就比ConcurrentHashMap效率更高,在读多写少的场景. ReadWriteMap.java public class ReadWriteMa
package com.java.concurrent; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; public class TestReadWriteLock { public static void main(String[] args) { final ReadWriteLockDemo rw2 = new ReadWr