"A reentrant mutual exclusionLock
with the same basic behavior and semantics as the implicit monitor lock accessed usingsynchronized
methods and statements, but with extended capabilities."
"Memory Synchronization
All
Lock
implementations must enforce the same memory synchronization semantics as provided by the built-in monitor lock, as described in Chapter 17 of The Java™ Language Specification:
lock
operation has the same memory synchronization effects as a successful Lock action.unlock
operation has the same memory synchronization effects as a successful Unlock action.Unsuccessful locking and unlocking operations, and reentrant locking/unlocking operations, do not require any memory synchronization effects."
Thanks,Franz
Thanks Gil!I will failback to my original (semi-practical) concern, using this renewed knowledge :)Suppose that we want to perform write operations surrounding both a j.u.c. Lock and synchronized mutual exclusion block and we want:
- these writes operations to not being moved inside the block and maintain their relative positions from it
- 2. the effects of the writes would be atomically readable from other threads
On Friday, May 18, 2018 at 2:30:08 AM UTC-5, Francesco Nigro wrote:Thanks Gil!I will failback to my original (semi-practical) concern, using this renewed knowledge :)Suppose that we want to perform write operations surrounding both a j.u.c. Lock and synchronized mutual exclusion block and we want:
- these writes operations to not being moved inside the block and maintain their relative positions from it
Preventing your appear-prior-to-lock-acquisition writes from "moving into the block" is subtly different from preventing their re-ordering with writes and reads that are within the block. Are you sure you want the former and not just the latter?
Preventing your appear-prior-to-lock-acquisition writes from "moving into the block" is subtly different from preventing their re-ordering with writes and reads that are within the block. Are you sure you want the former and not just the latter?