[concurrency-interest] AtomicReference weakCompareAndSet "May fail
robertkuhar at yahoo.com
Thu Feb 2 00:54:46 EST 2006
I was strolling through the Docs one day, and came upon the JDK 1.5 Javadocs
for Class java.util.concurrent.atomic.AtomicReference. The description for the
weakCompareAndSet method confuses me:
public final boolean weakCompareAndSet(V expect, V update)
Atomically set the value to the given updated value if the current
value == the expected value. May fail spuriously.
expect - the expected value
update - the new value
true if successful.
What does "May fail spuriously" mean? Why would it fail spuriously? When the
spurious failures occur, is the return value always false? Why would anyone
call this method having been warned that "spurious failure" is possible? I
think I'm missing something here.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the Concurrency-interest