If a thread holds a lock , what happens when the thread needs to enter another critical section controlled by the same lock?
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.
nothing: the system is able to determine which thread holds the lock to avoid a thread blocking itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With