Iterating over synchronized collection
java, multithreading, synchronized, vector
Solution
Yes, it will make it safe from `ConcurrentModificationException` at the expense of everything essentially being single-threaded.
Problem
I asked here a question about iterating over a `Vector`, and I have been answered with some good solutions. But I read about another simpler way to do it. I would like to know if it is good solution. ``` synchronized(mapItems) { Iterator<MapItem> iterator = mapItems.iterator(); while(iterator.hasNext()) iterator.next().draw(g); } ``` mapItems is a synchronized collection: Vector. Is that make the iterating over the `Vector` safe from `ConcurrentModificationException`?