You can never avoid observers being removed while iterating. The
The observer can even be removed WHILEWHILE you are trying to call its notify()notify() function. Therefore
Therefore I suppose you need a try/catchtry/catch mechanism. The
The lock is to ensure observerset is not changedd while copying the set of observers
lock(observers) set<Observer> os = observers.copy(); unlock(observers) for (Observer o: os) { try { o.notify() } catch (Exception e) { print "notification of "+o+"failed:"+e } }