I prefer Multimap.values().iterator()
if you don't care about the key. You should also try to stay away from using synchronized blocks as much as possible, because you cannot prioritize reads/writes effectively.
ReadWriteLock lock = new ReentrantReadWriteLock();
Lock writeLock = lock.writeLock();
public void removeCommands(Command value) {
try {
writeLock.lock();
for (Iterator it = multiMap.values().iterator(); it.hasNext();) {
if (it.next() == value) {
it.remove();
}
}
} finally {
writeLock.unlock();
}
}