Home > Software > Java > Core-Java
Interview Questions   Tutorials   Discussions   Programs   

Core-Java - Iterator in the Hash Map is fail-safe means what?

asked marvit November 25, 2014 11:40 AM  

Iterator in the Hash Map is fail-safe means what?


1 Answer

Best answer
answered By Apoorva Sharma   0  Best answer
Your question is not correct,Hash Map iterator are Fail-Fast.

Fail fast and Fail safe comes in to picture when we talk about concurrent access.

Fail fast iterator while iterating through collection throws concurrent modification exception when it finds out that collection is being modified by some other thread,so iterator fails quickly and cleanly.

Fail safe iterator do the copy of collection and iterate through it so no changes get reflected to original data so no concurrent modification exception. ConcurrentHash Map iterator are fail safe.
   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!