[concurrency-interest] synchronized vs ReentrantLock semantic

Doug Lea dl at cs.oswego.edu
Mon May 23 13:23:45 EDT 2005

Jean Morissette wrote:
> Hi all,
> 	I would like to know whether replacing "synchronized" statement by 
> ReentrantLock instances has the same semantic and meaning for the jvm?  By 
> exemple, I'm wondering whether ReentrantLock would allow reliable 
> transmission of values or sets of values from one thread to another through 
> shared variables?

yes. See the javadoc for the Lock interface, that says:

Memory Synchronization

All Lock implementations must enforce the same memory synchronization 
semantics as provided by the built-in monitor lock:

     * A successful lock operation acts like a successful monitorEnter 
     * A successful unlock operation acts like a successful monitorExit 



More information about the Concurrency-interest mailing list