this.subject = subject;
if(observers.contains(observer)) return; // return right away since we have that already. observers.add(observer);
Subject obj = (Subject) subject; synchronized (observers) { for (Iterator i = observers.iterator(); i.hasNext();) { Observer observer = (Observer) i.next(); observer.fireChange(obj); } }
observers.remove(observer);