| Author |
Fast fail behavior of collection
|
Vab Gandhi
Greenhorn
Joined: Jul 29, 2004
Posts: 6
|
|
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 ? Thanking in advance..... Vab
|
 |
Susanta Chatterjee
Ranch Hand
Joined: Aug 12, 2002
Posts: 102
|
|
Follow this tutorial: http://java.sun.com/docs/books/tutorial/collections/index.html Best of luck.
|
 |
Vab Gandhi
Greenhorn
Joined: Jul 29, 2004
Posts: 6
|
|
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
|
 |
Susanta Chatterjee
Ranch Hand
Joined: Aug 12, 2002
Posts: 102
|
|
Hi Vab, The Tutorial explains about Fast fail behavior indeed. Though the explanation is brief. General Purpose Implementation 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.
|
 |
 |
|
|
subject: Fast fail behavior of collection
|
|
|