title: Thread-safe way of incrementing value for specific key in a map inside another map
body: <p>So, I have one map inside another one, for example, it might be word-counter per account base:</p>
  
  <pre><code>Map&lt;Long, Map&lt;String, Long&gt;&gt;
  </code></pre>
  
  <p>What is proper thread-safe way to increment the counter?</p>
  
  <p>I guess it's possible to use ConcurrentHashMap and LongAdder like following:</p>
  
  <pre><code>private Map&lt;Long, Map&lt;GovernorLimitName, LongAdder&gt;&gt; status = new ConcurrentHashMap&lt;&gt; ();
  
  public void count (Long accountId, String word) {
    status.putIfAbsent (accountId, new ConcurrentHashMap&lt;GovernorLimitName, LongAdder&gt; ());
     synchronized (getStatus ().get (accountId)) {
       getStatus ().get (accountId).computeIfAbsent(limitName, k -&gt; new LongAdder()).increment();
     }
   }
  </code></pre>
  
  <p>I believe that syncronyzation here is required cause of race condition between getting inner map and performing comuteIfAbsent() on it, is that correct?</p>
  
  <p><strong>Updated</strong></p>
  
  <p>I assume that both submaps and adders might be removed, cause there might be other methods accessing that map. </p>