This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi All, I want to know more about fast fail behavior of collection objects.I know due to this ,if i try to chage my collection object while iterating on it throws ConcurrentModificationException.But if it is not allowed then how is it possible to update the underlying collection object (i mean reduce its size) using iterator objects' remove() method which removes the last object returned on next() method call? Also if i use Vector object it is possible to iterate and update collection object without any exception. Why this difference between Vector class object and object of other collection classes? Also i want know when to use Vector and when to use ArrayList ?
Thanx for reply, But sorry , i wanted precise description for Fast Fail behavior of Collection object. U suggested me tutorial about Collection API.So please give me any tutorial link if u know relating to fast fail behavior. Thanx in advance Vab
Joined: Aug 12, 2002
The Tutorial explains about Fast fail behavior indeed. Though the explanation is brief.
The problem is when you are iterating through a list using iterator interface in a thread, and another(or same) thread changes the underlying list, the iterator operation fails immediately. In case of Vector (or Hashtable), the Enumeration interface behaves inderterministic way under the same situation.