I am getting an exception when I try to remove elements from CopyOnWriteArrayList using an iterator. I have noticed that it is documented
Element-c
Since this is a CopyOnWriteArrayList it is totally safe to remove elements while iterating with forEach. No need for fancy algorithms.
CopyOnWriteArrayList
forEach
list.forEach(e -> { if (shouldRemove(e)) list.remove(e); });
EDIT: Well of course that works if you want to delete elements by reference, not by position.