Java Reference
In-Depth Information
throughout the topic—each operation randomly selects a value and searches for it in the col-
lection, and a small percentange of operations modify the contents of the collection.
Figure 13.3. Read-write Lock Performance.
Summary
Explicit
Lock
s offer an extended feature set compared to intrinsic locking, including greater
flexibility in dealing with lock unavailability and greater control over queueing behavior. But
ReentrantLock
is not a blanket substitute for
synchronized
; use it only when you
need features that
synchronized
lacks.
Read-write locks allow multiple readers to access a guarded object concurrently, offering the
potential for improved scalability when accessing read-mostly data structures.