multithreading - Does a Java Lock object enforce a happens-before relationship? -


java provides lock object in concurrency package according documentation provides more extensive locking operations can obtained using synchronized methods , statements.

the synchronized methods/blocks besides mutual exclusion, enforce happens-before relationship makes sure changed made variable 1 thread visible other.

does relationship occur when using lock object? observation guaranteed in case of synchronized block platforms?

does relationship occur when using lock object? observation guaranteed in case of synchronized block platforms?

yes, does.

there several actions create happens-before relationships , 1 of them synchronization (here), , java's lock object meant purpose.

read java's memory consistency properties oracle docs. except below highlight in link.

in below "extend these guarantees" means memory consistency properties "happens-before" relationships. lock class belongs subpackage of java.util.concurrent, guarantees memory consistency properties "happens-before" relationships , more.

the methods of classes in java.util.concurrent , subpackages extend these guarantees higher-level synchronization.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -