package kr.pe.acet.observer; import java.util.Observable; // ÀÌ ºÎºÐÀÌ ¿É¼­¹öÀÔ´Ï´Ù. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class EventSource extends Observable implements Runnable { public void run() { try { System.out.println("System.in~~~"); final InputStreamReader isr = new InputStreamReader( System.in ); final BufferedReader br = new BufferedReader( isr ); while( true ) { final String response = br.readLine(); setChanged(); System.out.println("setChanged"); /* * setChanged() Marks this Observable object as having been changed; the hasChanged method will now return true. * */ notifyObservers( response ); System.out.println("notifyObservers"); /* * notifyObservers() If this object has changed, as indicated by the hasChanged method, then notify all of its observers and then call the clearChanged method to indicate that this object has no longer changed. * */ } } catch (IOException e) { e.printStackTrace(); } } }