package observer_subject; import java.util.LinkedList; import java.util.Iterator; import org.omg.CORBA.ORB; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAHelper; class SubjectImpl extends SubjectPOA { private LinkedList observers = new LinkedList(); private boolean modif = false; private POA rootPOA; /* Classe de notification */ public class NotifThread extends Thread { public void run() { try { for(;;) { sleep(1000); if ( modif ) { notify_all(); modif = false; } } } catch (InterruptedException e) { System.out.println("erreur thread"); } } } /* Classe principale */ public SubjectImpl() { NotifThread t = new NotifThread(); t.start(); } public void attach(Observer o) throws DejaAttache { synchronized(observers) { if ( observers.contains(o) ) throw new DejaAttache(); observers.add(o); } } public void multiple_attach(Observer []ol) throws DejaAttache { synchronized(observers) { /* Vérifier qu'il n'y en a pas déjà un attaché */ for(int i=0;i