aspose file tools*
The moose likes Java in General and the fly likes Fast fail behavior of collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Fast fail behavior of collection " Watch "Fast fail behavior of collection " New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Fast fail behavior of collection