If a thread holds a lock
, what happens when the thread needs to enter another critical section
controlled by the same lock
?
views:
107answers:
3
+1
A:
nothing: the system is able to determine which thread holds the lock to avoid a thread blocking itself.
Maurice Perry
2010-04-24 11:23:20
+6
A:
Intrinsic locks (synchronized) in Java are reentrant, thus the JVM will recognize that the current thread already holds this lock and it will proceed.
There are also explicit locks, that are reentrant.
If a lock is not reentrant, you could for instance not use recursive methods.
PartlyCloudy
2010-04-24 11:24:20
A:
If a thread holds a lock then it can enter any methods(synchronized or non synchronized), but if any other thread wants to call a method then the methods should be non synchronized or it should wait to acquire the lock if it tries to call a synchronized method.
GK
2010-04-24 15:40:48