title: java.util.ConcurrentModificationException: concurrent access to hashmap
body: <p>In an implementation, i have written the following code. The try-catch block is in a method</p>
  
  <pre><code>try{
      InputVals iv = task.getInputVals();
      Map&lt;String, String&gt; map = iv.getAllValues();
      String a = map.get("value1");
      String b = map.get("value2");
      String x = funcxy.methodGetX();
      String y = funcxy.methodGetY();
      iv.setValue(xval, x);
      iv.setValue(yval,y);
  
      String []names = {"name1", "name2", "name3"}
      for(int i = 0; i&lt;names.length; i++ ){
           iv.setValue("name"+i, names[i] );
      }
    }
  </code></pre>
  
  <p>When I make concurrent request few times (not always) it throws "java.util.ConcurrentModificationException: concurrent access to hashmap" error. I tried using</p>
  
  <pre><code>Map&lt;String, String&gt; map= new ConcurrentHashMap&lt;String, String&gt;();
  map = iv.getAllValues();
  </code></pre>
  
  <p>But this didnt solve the issue. Can you help me out and let me know where I'm making the mistake. I cannot change the implementation of </p>
  
  <pre><code>InputVals iv = task.getInputVals();
  </code></pre>