Before you hit the downvote button, I need not share any minimally reproducible code coz I’m declaring the variable with
private final SortedSet<MyClass> mySet = Collections.synchronizedSortedSet(new TreeSet<>());
I’m getting ConcurrentModificationException when calling next() and this is not inside an iterator loop. The other possibility of some threads directly modifying the underlying set without synchronizing is eliminated from the very declaration of the variable. So why am I still getting the exception?