There's more...

There are other methods in the ReentrantLock class that can be used to obtain information about a Lock object:

  • getHoldCount(): This returns the number of times the current thread has acquired the lock
  • isHeldByCurrentThread(): This returns a Boolean value indicating whether the lock is owned by the current thread

Get Java 9 Concurrency Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.