I was looking up the difference between the two classes and this point came up in a lot of the answers with this blog being the source: http://javarevisited.blogspot.com/2010/1
When calling iterator.next()
, if any modification has been made between the moment the iterator was created and the moment next()
is called, a ConcurrentModificationException is immediately thrown. This is what fail-fast means.
The Enumerations returned by Hashtable don't have this behavior. They assume you know what you're doing, and their behavior, AFAIK, is undefined if you modify the map while iterating over it using one of its enumerations.