title: Concurrent Access HashMap
body: <p>The code below runs into the issue of <code>java.util.ConcurrentModificationException</code>. Is there any way to prevent this or allow this?</p>
  
  <pre><code>public void saveHomes() throws IOException {
      BufferedWriter br;
      br  = new BufferedWriter(new FileWriter(homeFile));
      Map&lt;String, Location&gt; homesLoc;
  
      System.out.println(homes2.keySet());
      for (String player : homes2.keySet()) {
          homesLoc = homes2.get(player);
          for (String name : homesLoc.keySet()) {
              br.write(player + " " + homesLoc.get(name) + " " + name);
              br.newLine();
              br.flush();
          }
      }
  
      br.close();
  }
  </code></pre>