Java: volatile boolean vs AtomicBoolean
What does AtomicBoolean do that a volatile boolean cannot achieve? ...
What does AtomicBoolean do that a volatile boolean cannot achieve? ...
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...