views:

203

answers:

3

Hi there

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

Many thanks

+1  A: 

Have a look at this question. It also mentions Java locking (which is always recursive).

extraneon
+1  A: 

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

wei
A: 

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.

Loop
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 V.
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
Loop