What is the difference between CopyOnWritearraylist and Collections.synchronizedList(..)? When should one be preferred over the other.
What is the difference between CopyOnWritearraylist and Collections.synchronizedList(..) ? When should one be preferred
Share
CopyOnWriteArrayListlist should be used when the number of reads vastly outnumber the number of writes. This is because you are trading unnecessary synchronization for expensive array copying on each write.For example, when you have a
Listof event listeners in a multi-threaded environment, you’d want to useCopyOnWriteArrayList, because