# HG changeset patch # User martin # Date 1425519340 28800 # Node ID ca3f43a932cfa542adf578148ff78fa60c567b2e # Parent afac043e9bf0ad9d1dae61af07d6b799a828f26e 8074578: Document memory visibility effects of Unsafe compareAndSwap methods Reviewed-by: psandoz, jrose, dholmes diff -r afac043e9bf0 -r ca3f43a932cf jdk/src/java.base/share/classes/sun/misc/Unsafe.java --- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Tue Mar 10 14:23:03 2015 -0700 +++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Wed Mar 04 17:35:40 2015 -0800 @@ -631,6 +631,10 @@ /** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. + * + *

This operation has memory semantics of a {@code volatile} read + * and write. Corresponds to C11 atomic_compare_exchange_strong. + * * @return {@code true} if successful */ public final native boolean compareAndSwapObject(Object o, long offset, @@ -640,6 +644,10 @@ /** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. + * + *

This operation has memory semantics of a {@code volatile} read + * and write. Corresponds to C11 atomic_compare_exchange_strong. + * * @return {@code true} if successful */ public final native boolean compareAndSwapInt(Object o, long offset, @@ -649,6 +657,10 @@ /** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. + * + *

This operation has memory semantics of a {@code volatile} read + * and write. Corresponds to C11 atomic_compare_exchange_strong. + * * @return {@code true} if successful */ public final native boolean compareAndSwapLong(Object o, long offset,