On Mon, 22 Jan 2024 07:11:08 GMT, Andrey Turbanov <aturba...@openjdk.org> wrote:
>> Since concurrent modification exception is thrown, it is clear that the List >> is being modified while comparing two list. Hence instead of copying the >> list locally, I have used iterators and comparing element by element in a >> `synchronized` method which ensures single thread is accessing the >> iterators. Without `synchronized` I guess it would again cause >> `concurrentModificationException`. > > Vector.iterator and Vector.subList.iterator are still check for modification > on iteration (see usages of the method > `java.util.AbstractList.SubList#checkForComodification`). It means, if vector > was concurrently modified during iteration - iteration will fail with the > `ConcurrentModificationException` Yes, which is why I am using Synchronized to handle `concurrentModificationException`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17462#discussion_r1461440337