ReadWriteLock(读写锁)

  • 读读不互斥:读读之间不阻塞;
  • 读写互斥:读阻塞写,写也会阻塞读;
  • 写写互斥:写写阻塞;

API

public interface ReadWriteLock {

    Lock readLock();

    Lock writeLock();
}

缺点

如果有大量的读线程,有可能引起写线程的“饥饿”

results matching ""

    No results matching ""