Each of the concurrent collections of the java.util.concurrent package implements (or extends, if it is an interface) one of the four interfaces of the java.util package: List, Set, Map, or Queue:
- The List interface has only one implementation: the CopyOnWriteArrayList class. The following is taken from the Javadoc of this class:
"all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array... The "snapshot" style iterator method uses a reference to the state of the array at the point that the iterator was created. This array never changes during the lifetime of the iterator, so interference is impossible and the iterator is guaranteed not to throw ConcurrentModificationException ...
Get Java 11 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.