- Chapter 12: Collections
- from Beginning Java 8 Language Features: Lambda Expressions, Inner Classes, Th reads, I/O, Collections,and Streams
- Publisher: Apress
- Released: August 2014
Fail-fast iterators (those returned by HashMap, ArrayList, and other non-thread-safe collections) iterate over the collection’s internal data structure, and they throw ConcurrentModificationException as soon as they detect a concurrent modification.
Fail-safe iterators (returned by thread-safe collections such as ConcurrentHashMap, CopyOnWriteArrayList) create a copy of the structure they iterate upon. They guarantee safety from concurrent modifications. Their drawbacks include excessive memory consumption and iteration over possibly out-of-date data in case the collection was modified
Share this highlighthttp://www.safaribooksonline.com/a/beginning-java-8/10379962/