This is ordinarily too costly, but may be more efficient than alternatives when traversal operations vastly outnumber mutations, and is useful when you cannot or don't want to synchronize traversals, yet need to preclude interference among concurrent threads. 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 {@code ConcurrentModificationException}. The iterator will not reflect additions, removals, or changes to the list since the iterator was created. Element-changing operations on iterators themselves ( {@code remove}, {@code set}, and {@code add}) are not supported. These methods throw {@code UnsupportedOperationException}.
All elements are permitted, including {@code null}.
Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a {@code CopyOnWriteArrayList}happen-before actions subsequent to the access or removal of that element from the {@code CopyOnWriteArrayList} in another thread.
This class is a member of the Java Collections Framework. @since 1.5 @author Doug Lea @param < E> the type of elements held in this collection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|