As in a few questions you specified to go through the AtomicInteger API which are important for the exam, I would like to ask a question about these API.
What's the difference between the two? I can see that in the latter there is an added line:compareAndSet
public final boolean compareAndSet(int expect,
int update)
Atomically sets the value to the given updated value if the current value == the expected value.
Parameters:
expect - the expected value
update - the new value
Returns:
true if successful. False return indicates that the actual value was not equal to the expected value.
weakCompareAndSet
public final boolean weakCompareAndSet(int expect,
int update)
Atomically sets the value to the given updated value if the current value == the expected value.
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.
Parameters:
expect - the expected value
update - the new value
Returns:
true if successful.
What do they actually mean with "may fail spuriously and moreover what kind of ordering are they talking about?May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.
EDIT: Ok in the API they suggest to check this link http://docs.oracle.com/javase/7/docs/ap ... l#Spurious out for an explanation of "spuroiously", however it's not that clear to me.
Is anybody able to express the concept in other words? That link seems to say nothing of concrete...
Thanks in advance.
The_Nick.