Difference between CopyOnWriteArrayList and ArrayList in Java.
GIAN Tutorials
2:50 AM
CopyOnWriteArrayList and ArrayList in Java. we have seen What is CopyOnWriteArrayList in Java and How it achieves thread-safety by creating a separate copy of List for each writes operation. Now let's see Some difference between ArrayList and CopyOnWriteArrayList in Java, which is another implementation of List interface : 1) First and foremost difference between CopyOnWriteArrayList and ArrayList in Java is that CopyOnWriteArrayList is a thread-safe collection while ArrayList is not thread-safe and can not be used in the multi-threaded environment. 2) The second difference between ArrayList and CopyOnWriteArrayList is that Iterator of ArrayList is fail-fast and throw ConcurrentModificationException once detect any modification in List once iteration begins but Iterator of CopyOnWriteArrayList is fail-safe and doesn't throw ConcurrentModificationException. 3) The third difference between CopyOnWriteArrayList vs ArrayList is that Iterator of former doesn...