-1

Can anyone explain what is meant by recursive locking in Java?

Many thanks

2
  • 'Recursive' locking would mean that a locking routine calls itself, which doesn't make much sense. Do you mean 'reentrant' locking? Please quote the text that you are trying to understand. Commented Apr 26, 2010 at 9:09
  • 3
    To understand recursive locking you first have to understand recursive locking Commented Apr 26, 2010 at 13:49

2 Answers 2

1

recursive locking in java means the same thread can lock the same mutex object twice and won't deadlock

Sign up to request clarification or add additional context in comments.

Comments

0

Intrinsic locks in Java are reentrant. Recursive locking is the single method (correct me if I'm wrong) to ensure "hand-over-hand" locking using intrinsic locks.

2 Comments

Hand over hand locking uses multiple lock objects (whether monitor or j.u.c.Lock), which can cause deadlocking. Recursive locking uses the same lock with the same thread multiple times
John, I was thinking of a scenario using the intrinsic lock of a guarding LOCK object to navigate a tree vs locking the entire tree. This is where lock reentrancy comes into play