Compare
synchronized (countList) {
while (iter.hasNext()) {
Entry<Long, Long> entry = iter.next();
if(entry.getVaue>0)
entry.output();
}
countList.clear();
}
with
synchronized (countList) {
while (iter.hasNext()) {
Entry<Long, Long> entry = iter.next();
if(entry.getVaue>0)
entry.output();
iter.remove();
}
}
Is there a real difference? I am guessing that maybe garbage collection is better for the collection.clear
method.