Correct me please!!
Here i understand the following things.
1) It is not recommended to use Enumeration(Since it does not have fail-fast behaviour -- Actually i don know this fail-fast).
2) We can use Iterator since it will fail-fast! But it might throw "ConcurrentModificationException".
3) I don understand this "the fail-fast behavior of iterators should be used only to detect bugs."
4) "It is possible to modify collections (all collection class objects) other than Vector Object concurrently " -- is it true ?
Thanks,
P.Jerald
Fail fast behaviour is failing to iterate over a Collection as soon as is discovered
that the Collection has been changed 'behind the back' of the iterator. Further
iterations most likely result in garbage.
The implementation is quite lean and mean: both the Collection and the iterator
keep a modification count. When the Collection is updated behind the iterator's
back, the Collection's modification count is incremented. When the iterator has
to iterate one more step it compares both modification counts; if they're not
equal that Exception is thrown. Modifying the Collection using the iterator itself
increments both modification counts.
Modifying a Collection behind an iterator's back is considered not done and a bug.
A Vector uses synchronized methods for the add, delete etc. methods so no
two modifications can occur at the same time.
kind regards,
Jos