An atomic operation completes as one indivisible update to its target. AtomicInteger has methods that add a delta, return the old value, or replace the value only if a comparison succeeds. Choose the return contract deliberately. getAndAdd and addAndGet update the same counter but return different values.
ConcurrentHashMap protects its own structure. A get followed by a put is still two operations, so another update can intervene on a full JVM. compute can combine the update for one key. It does not make changes to two account keys a transaction. The shipped browser supports the operations in these exercises. It executes your test sequentially, so passing checks proves the value contract rather than behavior under native contention.