Java Concurrency - Reentrant Lock

Java Conceptuel Diagram

About

A thread cannot acquire a lock owned by another thread but a thread can acquire a lock that it already owns. Allowing a thread to acquire the same lock more than once enables reentrant synchronization.

This describes a situation where:

  • synchronized code, directly or indirectly, invokes a method that also contains synchronized code,
  • and both sets of code use the same lock.

Without reentrant synchronization, synchronized code would have to take many additional precautions to avoid having a thread cause itself to block.

ReentrantLock

See also: javase/9/docs/api/java/util/concurrent/locks/ReentrantLock.html This implementation is a reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor lock accessed using synchronized methods and statements, but with extended capabilities.

Documentation / Reference





Discover More
Java Conceptuel Diagram
Java Concurrency - Monitor (Intrinsic|Implicit) Lock

Synchronization is built around an internal object property known as: intrinsic lock monitor lock implicit lock or simply monitor. Each object in Java is associated with a monitor, which a thread...



Share this page:
Follow us:
Task Runner