Class DecoratorReadWriteLockSet<E>

  • Type Parameters:
    E - The type of elements in the set.
    All Implemented Interfaces:
    ReadWriteLockCollection<E>, ReadWriteLockSet<E>, java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.locks.ReadWriteLock, java.util.Set<E>

    public class DecoratorReadWriteLockSet<E>
    extends DecoratorReadWriteLockCollection<E>
    implements ReadWriteLockSet<E>
    A thread-safe collection decorator that allows many readers but only one writer to access a set at a time. For operations that iterate over live collection data, a read or write lock should be acquired before the call to acquire the data and held until the data is consumed.
    Author:
    Garret Wilson
    • Constructor Detail

      • DecoratorReadWriteLockSet

        public DecoratorReadWriteLockSet​(java.util.Set<E> set)
        Set constructor with a default reentrant read/write lock.
        Parameters:
        set - The set this set should decorate.
        Throws:
        java.lang.NullPointerException - if the provided set is null.
      • DecoratorReadWriteLockSet

        public DecoratorReadWriteLockSet​(java.util.Set<E> set,
                                         java.util.concurrent.locks.ReadWriteLock lock)
        Set and read/write lock constructor.
        Parameters:
        set - The set this set should decorate.
        lock - The lock for controlling access to the set.
        Throws:
        java.lang.NullPointerException - if the provided set and/or lock is null.