-1

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

Many thanks

  • '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. – Kilian Foth Apr 26 '10 at 09:09
  • 3
    To understand recursive locking you first have to understand recursive locking – John Vint Apr 26 '10 at 13:49

2 Answers2

1

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

wei
  • 11
  • 1
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.

Ovidiu Lupas
  • 185
  • 5
  • 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 Vint Apr 26 '10 at 13:51
  • 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 – Ovidiu Lupas Apr 26 '10 at 20:17