### Question:
StoreStatsService extends ServiceThread { public AtomicLong getSinglePutMessageTopicTimesTotal(String topic) { AtomicLong rs = putMessageTopicTimesTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicTimesTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; } StoreStatsService(); long getPutMessageEntireTimeMax(); void setPutMessageEntireTimeMax(long value); long getGetMessageEntireTimeMax(); void setGetMessageEntireTimeMax(long value); long getDispatchMaxBuffer(); void setDispatchMaxBuffer(long value); @Override String toString(); long getPutMessageTimesTotal(); long getPutMessageSizeTotal(); HashMap<String, String> getRuntimeInfo(); @Override void run(); @Override String getServiceName(); AtomicLong getGetMessageTimesTotalFound(); AtomicLong getGetMessageTimesTotalMiss(); AtomicLong getGetMessageTransferedMsgCount(); AtomicLong getPutMessageFailedTimes(); AtomicLong getSinglePutMessageTopicSizeTotal(String topic); AtomicLong getSinglePutMessageTopicTimesTotal(String topic); Map<String, AtomicLong> getPutMessageTopicTimesTotal(); Map<String, AtomicLong> getPutMessageTopicSizeTotal();  }### Answer:
@Test public void getSinglePutMessageTopicTimesTotal() throws Exception { final StoreStatsService storeStatsService = new StoreStatsService(); int num = Runtime.getRuntime().availableProcessors() * 2; for (int j = 0; j < 100; j++) { final AtomicReference<AtomicLong> reference = new AtomicReference<>(null); final CountDownLatch latch = new CountDownLatch(num); final CyclicBarrier barrier = new CyclicBarrier(num); for (int i = 0; i < num; i++) { new Thread(new Runnable() { @Override public void run() { try { barrier.await(); AtomicLong atomicLong = storeStatsService.getSinglePutMessageTopicTimesTotal("test"); if (reference.compareAndSet(null, atomicLong)) { } else if (reference.get() != atomicLong) { throw new RuntimeException("Reference should be same!"); } } catch (InterruptedException | BrokenBarrierException e) { e.printStackTrace(); } finally { latch.countDown(); } } }).start(); } latch.await(); } }