<分区>
Possible Duplicate:
java.util.ConcurrentModificationException on ArrayList
我正在尝试从线程内的列表中删除项目。我收到了 ConcurrentModificationException
。我读到这个link它与从列表中删除项目有关。我将示例代码放在下面。在我的情况下,如果没有这个异常(exception),我该如何正确地做到这一点。
try
{
for(Game game:appDeleg.getGlobalGames().getGames())
{
if(game.getOwner().getId().equals(params[0]))
{
synchronized (appDeleg.getGlobalGames().getGames())
{
appDeleg.getGlobalGames().getGames().remove(game);
}
}
}
}
catch (Exception e)
{
e.printStackTrace();
return "noconnection";
}