I would like to collect some metrics from various places in a web app. To keep it simple, all these will be counters and therefore the only modifier operation is to incremen
In Java 8:
ConcurrentHashMap map = new ConcurrentHashMap<>(); map.computeIfAbsent("key", k -> new LongAdder()).increment();