Las Bibliotecas de JavaLas Bibliotecas de Java\ReadWriteLock (interface) java.util.concurrent.locks

ReadWriteLock (interface) java.util.concurrent.locks

public interface ReadWriteLock

Las clases que implementan esta interfaz, como ReentrantReadWriteLock, permiten obtener dos cerrojos sincronizados:

ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();

Lock readLock = rwl.readLock();

Lock writeLock = rwl.writeLock();

 

De forma que los cerrojos readLock y writeLock ya llevan la cuenta de que pueden haber varios readers a la vez, pero sólo un writer, y que hay que darle prioridad al writer:

principio