title: Trying to understand the accepted answer - Thread Safe Map of Queues
body: <p><a href="https://stackoverflow.com/questions/26496437/thread-safe-map-of-queues">Thread safe Map of Queues</a></p>
  
  <p>The above question has a design implementation VERY similar to my own. I understand why it's not thread safe, but the accepted "pattern" is throwing me for a loop. I don't quite get how to implement it or what it does in relationship to the question.</p>
  
  <pre><code>    boolean send = false;
      System.out.println("MailCenter Size Start: " + mailBox.keySet().size());
      if (parsedInput.size() == 3) {
          for (String s : writers.keySet()) {
              if (!s.equals(parsedInput.get(1))) {
                  send = true;
              }
          }
          if (send) {
              mailMessage.add(noAnsiName + ": " + parsedInput.get(2));
              mailBox.putIfAbsent(parsedInput.get(1), mailMessage);
              System.out.println("Current mail message is: " + mailMessage.peek());
              out.println("SERVER You have sent mail to " + parsedInput.get(1) + ".");
          }
          System.out.println("MailCenter Size Middle: " + mailBox.keySet().size());
      } else {
          int loop = 0;
          for (Map.Entry entry : mailBox.entrySet()) {
              System.out.println(entry.getKey() + ":\t" + entry.getValue());
              System.out.println("*** LOOP STATUS *** " + loop);
              loop++;
          }
      }
  </code></pre>