title: java.util.ConcurrentModificationException when trying to update global variable
body: <p>I have the following code in a method ( Utils.currentPrinters is a static JsonObject ):</p>
  
  <pre><code>    JsonObject printers = Utils.currentPrinters;
  
      for (Map.Entry&lt;String, ?&gt; entry : Utils.currentPrinters.entrySet()) {
  
          String key = entry.getKey();
  
          JsonObject printer = (JsonObject) entry.getValue();
  
          if (...) {
              printers.remove(key);
          }
      }
  
      Utils.currentPrinters = printers;
  </code></pre>
  
  <p>There are two threads that actually call this method. If it's only one, there are no problems at all. But after running few seconds with two threads, it crashes with the following Exception:</p>
  
  <pre><code> 05-13 12:01:43.168    5739-5739/com.wasp.pos.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.util.ConcurrentModificationException
          at com.google.gson.internal.LinkedTreeMap$LinkedTreeMapIterator.nextNode(LinkedTreeMap.java:541)
          at com.google.gson.internal.LinkedTreeMap$EntrySet$1.next(LinkedTreeMap.java:565)
          at com.google.gson.internal.LinkedTreeMap$EntrySet$1.next(LinkedTreeMap.java:563)
          at com.wasp.pos.app.server.PrintersFinder.clearPrinters(PrintersFinder.java:184)
          at com.wasp.pos.app.server.PrintersFinder.access$000(PrintersFinder.java:30)
          at com.wasp.pos.app.server.PrintersFinder$1UpdateListThread.run(PrintersFinder.java:124)
          at android.os.Handler.handleCallback(Handler.java:615)
          at android.os.Handler.dispatchMessage(Handler.java:92)
          at android.os.Looper.loop(Looper.java:153)
          at android.app.ActivityThread.main(ActivityThread.java:4987)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I could not really find anything that fixes this, ConcurrentMap or synchronized (printers) did not fixed it. Please, help.</p>