Your initial question seems to require an iterator that sees live updates to the base collection while remaining in streaming mode. This is an extremely costly problem to solve in the general case, so none of the standard collection classes do this.
There are many ways to solve partial solutions to a problem, and in your application one of them may be sufficient.
Jason provides a concrete way to ensure thread safety and avoid throwing a ConcurrentModificationException , but only at the cost of survivability.
Javamann mentions two specific classes in the java.util.concurrent package that solve the same problem without blocking, where scalability is critical. They ship only with Java 5, but there are various projects that support the package features in earlier versions of Java, including this one , although they will not have such good work in earlier JREs.
If you are already using some Apache Commons libraries, then, as jacekfoo points out, the framework contains several useful classes.
You might also consider browsing the Google Collections framework .
Bill michell
source share