Interface ThreadLock

All Superinterfaces:
Lock
All Known Subinterfaces:
RecursiveLock, RecursiveThreadGroupLock

public interface ThreadLock extends Lock
Extending the Lock features with convenient functionality.
  • Method Details

    • isLockedByOtherThread

      boolean isLockedByOtherThread()
      Query whether the lock is hold by the a thread other than the current thread.
    • isOwner

      boolean isOwner(Thread thread)
      Query whether the lock is hold by the given thread.
    • getOwner

      Thread getOwner()
      Returns:
      the Thread owning this lock if locked, otherwise null
    • validateLocked

      void validateLocked() throws RuntimeException
      Throws:
      RuntimeException - if current thread does not hold the lock
    • unlock

      void unlock(Runnable taskAfterUnlockBeforeNotify)
      Execute the Runnable taskAfterUnlockBeforeNotify while holding the exclusive lock.

      Then release the lock.