" - , , , "
, ArrayList, , ArrayList synchronized.
class MyClasss{
private final ArrayList list;
......
......
......
}
MyClass, , / , .
class MyClasss{
private final ArrayList list;
......
......
......
public void fun(){
synchronized(this){
list.add(....)
}
}
? , , ConcurrentModificationException JVM.
ConcurrentModificationException java, Collection. , , .
So, if you are synchronize Collection, then the simultaneous modification of the modification counter will not occur, as a result of which the value will not be selected ConcurrentModificationException.
Hope this helps.
source
share