You get java.util.ConcurrentModificationException when you try to access the HashMap from more than one threads and at least one thread tries to modify it.
If multiple threads access a hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with a key that an instance already contains is not a structural modification.) Java HashMap
One way to solve it, is to wrap the Map using the Collections.synchronizedMap method. This way you will restrict the access to the HashMap only to one thread at a time ( call to a HashMap function) . Keep in mind that synchronizing the access to the map will make the calls a lot slower.
(e.x. of Collections.synchronizedMap)
Map<String, String> map = Collections.synchronizedMap(new HashMap<String, String>());