Java tutorial
//package com.java2s; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; public class Main { public static void setLong(ConcurrentMap<String, AtomicLong> map, String key, long newValue) { map.putIfAbsent(key, new AtomicLong(0)); map.get(key).getAndSet(newValue); } }