JDK-4996165 : (spec) weakCompareAndSet has different memory effects from compareAndSet
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-02-18
  • Updated: 2017-05-16
  • Resolved: 2004-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b42Fixed
Description
weakCompareAndSet and compareAndSet are intended to have slightly
different semantics, but this is not correctly specified in
java/util/concurrent/atomic/package.html

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b42 tiger-beta2
14-06-2004

SUGGESTED FIX --- /tmp/geta21340 2004-02-17 19:03:10.518685000 -0800 +++ package.html 2004-02-17 18:56:05.385307000 -0800 @@ -55,30 +55,34 @@ <pre> class Sequencer { private AtomicLong sequenceNumber = new AtomicLong(0); public long next() { return sequenceNumber.getAndIncrement(); } } </pre> -<p>The memory effects for accesses and updates of atomics follow the +<p>The memory effects for accesses and updates of atomics generally follow the rules for volatiles: <ul> <li> <tt>get</tt> has the memory effects of reading a <tt>volatile</tt> variable. <li> <tt>set</tt> has the memory effects of writing (assigning) a <tt>volatile</tt> variable. - <li> <tt>compareAndSet</tt>, <tt>weakCompareAndSet</tt>, -and other read-and-update operations -have the memory effects of both reading and -writing <tt>volatile</tt> variables. - + <li><tt>weakCompareAndSet</tt> atomically reads and conditionally + writes a variable, is ordered with respect to other + memory operations on that variable, but otherwise acts as an + ordinary non-volatile memory operation. + + <li> <tt>compareAndSet</tt> + and all other read-and-update operations + have the memory effects of both reading and + writing <tt>volatile</tt> variables. </ul> <p>In addition to classes representing single values, this package contains <em>Updater</em> classes that can be used to obtain <tt>compareAndSet</tt> operations on any selected <tt>volatile</tt> field of any selected class. {@link java.util.concurrent.atomic.AtomicReferenceFieldUpdater}, {@link
11-06-2004

PUBLIC COMMENTS (spec) weakCompareAndSet has different memory effects from compareAndSet
10-06-2004

EVALUATION The suggested fix is being provided by the JSR-166 Expert Group. ###@###.### 2004-02-17
17-02-2004