On 08/11/2016 11:56 PM, Martin Buchholz wrote: > I can imagine a machine that has a native cas instruction, but no native > exchange instruction, but no one ever got fired for optimizing for x86.
...which would be less of an issue once we switch to proper-boolean VarHandles, not the int-simulation. This way, implementations may choose how to implement boolean getAndSet. Probably in Unsafe, but that would still be lower and more reusable than in AtomicBoolean alone. > public final boolean getAndSet(boolean newValue) { > return (int)VALUE.getAndSet(this, (newValue ? 1 : 0)) != 0; > } Yup. Thanks, -Aleksey