Search code examples
javalistconcurrentmodification

Why CopyOnWriteLinkedList does not exist?


As ConcurrentModificationException(CME) can be thrown while strustural change in list during iteration. I see CopyOnWriteArrayList exist in jdk 1.6 to handle with CME but CopyOnWriteLinkedList does not. Whats the reason behind it? i am sure there must be logic behind it.


Solution

  • CopyOnWriteArrayList is based on an array. All mutative operations make a copy of this array, make a change and replace current array with the updated one. Copying an array is fast. Copying a chain of linkes is lots of work