I was going through the documentation on the Internet about reentrant locks. Also read the examples everywhere about nested "synchronize"d methods and how the lock needs to be acquired only once.
But I don't understand what is "re-enter"ing here? From what I could gather, there's lock()
which blocks, tryLock()
which doesn't, and the locking is bypassed if thread is unavailable. And the tryLock()
is what makes ReentrantLock
different from the synchronized
keyword.
Does it mean:
- same thread is allowed to re-enter the locked section if it holds the lock?
- does hold count keep incrementing every time same thread re-enters?
- if so, is it sufficient to call
unlock()
only once, or it needs to be called as many times thread has re-entered?
Or is there something else to re-entering that I'm missing out?