刪除元素爲了避免ConcurrentModificationException,我訴諸於以下內容:從屬性
List<String> tobeRemoved = new ArrayList<String>();
for (Object propertyKey : suppliedContent.keySet()) {
key = (String) propertyKey;
if (EqualityUtils.isMatching(rgx, key)) {
tobeRemoved.add(key);
}
}
for (String o : tobeRemoved) {
suppliedContent.remove(o);
}
有一個更清潔的方式?
能否請您提供一個例子嗎? – JAM
http://tech.puredanger.com/2009/02/02/java-concurrency-bugs-concurrentmodificationexception/ – mellamokb
謝謝Nambari。 – JAM