title: Consume elements from ConcurrentHashMap
body: <p>I use a ConcurrentHashMap to buffer messages for a websocket.</p>
  
  <p>Every 200ms the buffer is sent in one JSON String. afterwards I want to remove the entry from the Map.</p>
  
  <p>This is not safe I guess, because during the foreach there might come new messages to the buffer.</p>
  
  <pre><code>String sendString;
  for(String msg : buffer.values()){
      sendString += msg;
  }
  ws.send(sendString);
  buffer.clear();
  </code></pre>
  
  <p>How could I safely remove the Elements?</p>