示例#1
0
 public void run() {
   for (int i = 0; i < 100; ++i) {
     if (cooler.isEnabled()) {
       currentTemperatur -= Math.random() * 3.0d;
     } else if (heater.isEnabled()) {
       currentTemperatur += Math.random() * 3.0d;
     } else {
       currentTemperatur += 1.0d;
     }
     System.out.println("Temp is now: " + currentTemperatur);
     eventDispatcher.fireBlocked(new TemperatureChangeEvent(this, currentTemperatur));
     try {
       Thread.sleep(200);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
示例#2
0
 public void registerListers() {
   eventDispatcher.registerListener(cooler, this);
   eventDispatcher.registerListener(heater, this);
 }