Class KeyedLock<K>

java.lang.Object
com.cryptomorin.xseries.profiles.lock.KeyedLock<K>
All Implemented Interfaces:
AutoCloseable

@Internal public final class KeyedLock<K> extends Object implements AutoCloseable
A lock associated to an object that keeps track of how many threads are currently using this lock until none are left in which case it removes itself. These locks should be registered in a KeyedLockMap.
  • Field Details

    • lock

      protected final Lock lock
    • key

      protected final K key
    • pendingTasks

      protected int pendingTasks
      This does not need to be volatile because access to this property is entirely synchronized (in KeyedLockMap) and no two threads will access this at the same time.
  • Constructor Details

  • Method Details

    • lock

      public void lock()
    • unlock

      public void unlock()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object