java.util.concurrent.atomic · java.base · since Java 1.8

LongAdder

declaration
public class LongAdder extends Striped64 implements Serializable

Contention-striped counter: increments hit per-thread cells, sum() aggregates. Beats AtomicLong decisively for hot write-mostly counters (metrics, hit counts).

Key methods

void increment() / void add(long x)Nearly contention-free writes.
long sum()Aggregate — weakly consistent under concurrent writes (fine for stats).