I hate to be picky... but why not iterate over connections.keySet() (wrapped in the ReadWriteLock readLock that protects it) instead?