/** thread safe */
class Counter {
private final AtomicLong count = new AtomicLong();
void increment(long amount) {
if (amount < 1) {
throw new IllegalArgumentException("Only increments!");
}
this.count.addAndGet(amount);
}
}
/** thread safe */
class Counter {
private final LongAdder count = new LongAdder();
void increment(long amount) {
if (amount < 1) {
throw new IllegalArgumentException("Only increments!");
}
this.count.add(amount);
}
}