Why does ArrayList not throw ConcurrentModificationException when modified from multiple threads?

后端 未结 5 1457
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 03:38

ConcurrentModificationException : This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible.<

5条回答
  •  北海茫月
    2021-01-14 04:38

    Because you are not using an iterator, there is no chance of a ConcurrentModificationException being thrown.

    Calling remove(0) will simply remove the first element. It might not be the same element intended by the caller if another thread removes 0 before execution completes.

提交回复
热议问题