Interface ReadWriteThreadLock.Lock

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void lock()
      Acquires the lock, blocking to wait until the lock can be acquired.
      boolean tryLock​(long timeout, java.util.concurrent.TimeUnit timeUnit)
      Tries acquiring the lock, blocking to wait until the lock can be acquired or the specified time has passed, then returns true in the first case and false in the second case.
      void unlock()
      Releases the lock.
    • Method Detail

      • lock

        void lock()
        Acquires the lock, blocking to wait until the lock can be acquired.

        If the thread executing this method is interrupted, this method will throw a runtime exception.

      • tryLock

        boolean tryLock​(long timeout,
                        @NonNull
                        java.util.concurrent.TimeUnit timeUnit)
        Tries acquiring the lock, blocking to wait until the lock can be acquired or the specified time has passed, then returns true in the first case and false in the second case.

        If the thread executing this method is interrupted, this method will throw a runtime exception.

        This method will try acquiring the lock first before checking for timeout. A non-positive timeout means the method will return immediately after the first try. This behavior is similar to a ReentrantReadWriteLock.

        Parameters:
        timeout - the maximum time to wait for the lock
        timeUnit - the unit of the timeout
        Returns:
        true if the lock was acquired
      • unlock

        void unlock()
        Releases the lock. This method does not block.