@Override public void run() { while (monitor.isAlive()) { inputSemaphore.take(); switch (input.getChoice()) { case ClockInput.SET_TIME: setTime = input.getValue(); break; case ClockInput.SET_ALARM: monitor.setAlarm(input.getValue()); setTime = -1; break; case ClockInput.SHOW_TIME: if (setTime > -1) { monitor.setTime(setTime); setTime = -1; } monitor.disableAlarm(); break; } } }
public ButtonWatcher(ClockInput i, Monitor m) { input = i; inputSemaphore = input.getSemaphoreInstance(); monitor = m; }