以下是我的代码段:
ArrayList<Contact> contactList = presenter.getContactList();
for (Contact contact : contactList) {
if (null != contact) {
String name = contact.getVehicleNumber();
final ArrayList<Vehicle> vehicleList = contact.getVehicles();
if (vehicleList != null && vehicleList.size() > 0) {
name = vehicleList.get(0).getVehicleNumber();
}
}
}
我得到java.util.ConcurrentModificationException
。
对于类似的问题,我已经通过其他答案,但是我没有通过添加或删除项目来对原始列表进行任何修改。奇怪的是,它并不总是发生。
如果在执行此代码段的同时Exception
被其他线程修改了,会发生这种情况吗?
堆栈跟踪,
presenter.getContactList()