java.util.concurrent.locks · java.base · since Java 1.5

ReentrantReadWriteLock

declaration
public class ReentrantReadWriteLock implements ReadWriteLock, Serializable

A lock pair: shared read lock (many concurrent readers) and exclusive write lock. Pays off for read-mostly data with non-trivial critical sections.

  • Under heavy read traffic consider StampedLock's optimistic reads for another gear

Key methods

Lock readLock() / Lock writeLock()The pair; write excludes everything.