Class Locker

java.lang.Object
org.eclipse.jetty.util.thread.Locker

public class Locker extends Object

Convenience auto closeable ReentrantLock wrapper.

 try (Locker.Lock lock = locker.lock())
 {
   // something
 }
 
  • Field Details

  • Constructor Details

    • Locker

      public Locker()
  • Method Details

    • lock

      public Locker.Lock lock()

      Acquires the lock.

      Returns:
      the lock to unlock
    • lockIfNotHeld

      @Deprecated public Locker.Lock lockIfNotHeld()
      Deprecated.
      use lock() instead
      Returns:
      the lock to unlock
    • isLocked

      public boolean isLocked()
      Returns:
      whether this lock has been acquired
    • newCondition

      public Condition newCondition()
      Returns:
      a Condition associated with this lock