java.util.ConcurrentModificationException error
<p>I recently bumped into an error when running my runnable which updates the location of minecarts. <code>Main.UvehicleLocation2</code> is a <code>HashMap</code></p>

<pre class="lang-none prettyprint-override"><code>[22:36:59] [Craft Scheduler Thread - 607/WARN]: Exception in thread "Craft Scheduler Thread - 607" 
[22:36:59] [Craft Scheduler Thread - 607/WARN]: org.apache.commons.lang.UnhandledException: Plugin CreativeControlByKubqoA v2.2.3 generated an exception while executing task 3019245
at org.bukkit.craftbukkit.v1_9_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at java.util.ArrayList.&lt;init&gt;(ArrayList.java:177)
at me.kubqoa.creativecontrol.tasks.VehiclesUpdateDB.run(VehiclesUpdateDB.java:19)
at org.bukkit.craftbukkit.v1_9_R1.scheduler.CraftTask.run(CraftTask.java:71)
at org.bukkit.craftbukkit.v1_9_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
... 3 more
</code></pre>

<p>This is the code:</p>

<pre><code>@Override
public void run() {
    List&lt;Location&gt; locations1 = new ArrayList&lt;Location&gt;(Main.UvehiclesLocation2.keySet());
    for (Location location : locations1) {
        VehicleHelper.updateVehicle(location,Main.UvehiclesLocation2.get(location));
    }
}
</code></pre>