1

While going through the advantages of ReEntrantLock one of them is:

With ReentrantLock, a thread can acquire lock on the same object more than once.

I came across this answer which states that there would be a deadlock in the get(index). Can someone please explain how can a deadlock occur at that point, if we are not using any synchronization on get(index)?

UseCase of multiple locks on same object

ghostrider
  • 2,046
  • 3
  • 23
  • 46
  • That's weird, how would you deadlock at method that's not even implemented – Ecto May 03 '20 at 10:45
  • Looks like a misprint. If lock is not repentant then you would deadlock at `set()` not `get()`. Also every recursive synchronized method will also deadlock if using non-reentrant lock. – Ivan May 04 '20 at 04:27

0 Answers0