atomicboolean

Java: volatile boolean vs AtomicBoolean

What does AtomicBoolean do that a volatile boolean cannot achieve? ...

AtomicBoolean vs synchronized block

I was trying to cut thread contention in my code by replacing some synchronized blocks with AtomicBoolean. Here's an example with synchronized: public void toggleCondition() { synchronized (this.mutex) { if (this.toggled) { return; } this.toggled = true; // do other stuff } } And t...