jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
changeset 41415 9c298252e385
parent 40817 4f5fb115676d
child 45518 4a116dd82fb5
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Mon Oct 10 15:46:14 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Mon Oct 10 15:58:42 2016 -0700
@@ -148,15 +148,37 @@
      * if the current value {@code == expectedValue},
      * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
      *
+     * @deprecated This method has plain memory effects but the method
+     * name implies volatile memory effects (see methods such as
+     * {@link #compareAndExchange} and {@link #compareAndSet}).  To avoid
+     * confusion over plain or volatile memory effects it is recommended that
+     * the method {@link #weakCompareAndSetPlain} be used instead.
+     *
      * @param expectedValue the expected value
      * @param newValue the new value
      * @return {@code true} if successful
+     * @see #weakCompareAndSetPlain
      */
+    @Deprecated(since="9")
     public final boolean weakCompareAndSet(int expectedValue, int newValue) {
         return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
+     * Possibly atomically sets the value to {@code newValue}
+     * if the current value {@code == expectedValue},
+     * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}.
+     *
+     * @param expectedValue the expected value
+     * @param newValue the new value
+     * @return {@code true} if successful
+     * @since 9
+     */
+    public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) {
+        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+    }
+
+    /**
      * Atomically increments the current value,
      * with memory effects as specified by {@link VarHandle#getAndAdd}.
      *