How to atomically update the value of ConcurrentMap in multithreaded application?
问题 I have a ConcurrentMap which I need to populate from multithread application. My map is shown below: private final ConcurrentMap<String, AtomicLongMap<String>> deviceErrorHolder = Maps.newConcurrentMap(); Below is my method which is called from multithreaded application at very fast rate so I need to make sure it is fast. public void addDeviceErrorStats(String deviceName, String errorName) { AtomicLongMap<String> errorMap = deviceErrorHolder.get(deviceName); if (errorMap == null) { errorMap =