Android : Concurrent modification exception

on Wednesday, August 13, 2014


My following code is throwing concurrent modification exception and I am not able to solve it. Help!



{
long now = new Date().getTime();
Set<String> keyset = requests.keySet();
Iterator<String> iterator = keyset.iterator();

while (iterator.hasNext()) {
String packetId = iterator.next();
RequestHolder entry = requests.get(packetId);
if (entry.isExpired(now)) {
entry.getListener().onTimeout(packetId);
iterator.remove();
}
}
}

0 comments:

Post a Comment