Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

November 13, 2009

Fail fast and fail safe iterator

Fail Fast :
When we iterate over a collection, if during iteration, we modify the collection , then the iteration halts and we get "ConcurrentModificationException" (e.g Hashtable)

Fail Safe :
During iteration, a separate copy of the colleciton object is created and iteration occurs on that. So if we modify it during the iteration process, it wont throw an exception.(e.g HashMap)

Best Explanation (with example) : http://www.certpal.com/blogs/2009/09/iterators-fail-fast-vs-fail-safe/

1 comment:

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!