In general you are right, but ... IIRC I once modified ArrayList(Collection) and Vector(Collection) but not HashSet(Collection) to avoid iterators due to this problem. And Collections.synchronizedXxx cannot know how other software makes use of it.
On Sat, Dec 28, 2019 at 1:50 AM Roman Leventov <leventov...@gmail.com> wrote: > I think Javadocs for Collections.synchronizedXxx() should mention not > only "traversing it via Iterator, Spliterator or Stream" as something that > must be synchronized externally, but also cases when a synchronized > collection is an argument to a bulk collection method, including: > - new ArrayList(syncList), new HashSet(syncSet), etc. > - List.copyOf(syncList) > - otherColl.addAll(syncList), otherColl.removeAll(syncList), > otherMap.putAll(syncMap). > > Though this is logically inferable, this is far from being obvious and > apparent. >