Couple of things here. There's no reason the code you've written won't work (ignoring typos, that is
). Iterators are safe to run in tandem as long they don't actually change the underlying collection (for example by calling iterator.remove() method).
On the other hand, is there any reason you can't call the size() method directly on the collection to get it's size? That way you would only need one iterator.