AtomicInteger uses compare-and-swap (CAS) processor instruction to update the counter. It works great, until under high contention it doesn’t run into a spin lock, as the operation is retried in infinite loop, until it succeeds. Java8 LongAdder does not try to compete for accessing the value to increment, but instead – saves the value in […]
Read more