Is there any reason as to why I should change the code to use an explicit iterator and run an iterator.remove()
Under the covers, the iterator that CHM uses calls map.remove(key)
itself. See the code below.
That said, removing from the iterator is the proper pattern and its always good to use common patterns if possible. For example, if you copy your code to use a different map or downgrade the map in this code to not be a CHM then your code won't break if you are using the iterator.
abstract class HashIterator {
...
public void remove() {
if (lastReturned == null)
throw new IllegalStateException();
ConcurrentHashMap.this.remove(lastReturned.key);
lastReturned = null;
}