Class ReentrantReadWriteMutex

  • All Implemented Interfaces:
    ReadWriteMutex

    public class ReentrantReadWriteMutex
    extends java.lang.Object
    implements ReadWriteMutex
    A re-entrant read-write mutex wrapper.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void lockForReading​(java.lang.Runnable callable)
      Lock the config for a read operation that must be read atomic.
      <V> V lockForReading​(java.util.function.Supplier<V> callable)
      Lock the config for a read operation that must be read atomic.
      void lockForWriting​(java.lang.Runnable callable)
      Lock the config for a write operation that must be write atomic, and could interfere with read operations.
      <V> V lockForWriting​(java.util.function.Supplier<V> callable)
      Lock the config for a write operation that must be write atomic, and could interfere with read operations.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReentrantReadWriteMutex

        public ReentrantReadWriteMutex()
    • Method Detail

      • lockForReading

        public void lockForReading​(java.lang.Runnable callable)
        Description copied from interface: ReadWriteMutex
        Lock the config for a read operation that must be read atomic.
        Specified by:
        lockForReading in interface ReadWriteMutex
        Parameters:
        callable - The callable operation.
      • lockForReading

        public <V> V lockForReading​(java.util.function.Supplier<V> callable)
        Description copied from interface: ReadWriteMutex
        Lock the config for a read operation that must be read atomic.
        Specified by:
        lockForReading in interface ReadWriteMutex
        Type Parameters:
        V - The read return value type.
        Parameters:
        callable - The enclosed callable to be run inside read lock.
        Returns:
        The supplied value.
      • lockForWriting

        public void lockForWriting​(java.lang.Runnable callable)
        Description copied from interface: ReadWriteMutex
        Lock the config for a write operation that must be write atomic, and could interfere with read operations.
        Specified by:
        lockForWriting in interface ReadWriteMutex
        Parameters:
        callable - The callable operation.
      • lockForWriting

        public <V> V lockForWriting​(java.util.function.Supplier<V> callable)
        Description copied from interface: ReadWriteMutex
        Lock the config for a write operation that must be write atomic, and could interfere with read operations.
        Specified by:
        lockForWriting in interface ReadWriteMutex
        Type Parameters:
        V - The write return value type.
        Parameters:
        callable - The callable operation.
        Returns:
        The supplied value.