ReentrantReadWriteLock

对线程锁的封装, 更方便的操作锁;

ReentrantReadWriteLock 内分为 writeLock 和 readLock; 多个读锁不互斥,读锁与写锁互斥

// 写锁
infoLock.writeLock().lock();
infoLock.writeLock().unlock();

// 读锁
infoLock.readLock().lock();
infoLock.readLock().unlock();

results matching ""

    No results matching ""