예제 #1
0
    private void tick() throws Exception {
      if (active.getAndSet(true)) return;

      on(this);
      activeSchedule = scheduler.after(duration * 1000L);
      activeSchedule.then(
          (p) -> {
            off(State.this);
            active.set(false);
            return null;
          });
    }
예제 #2
0
 public void close() {
   if (closed.getAndSet(true)) {
     if (waitSchedule != null)
       try {
         waitSchedule.close();
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     if (activeSchedule != null) activeSchedule.cancel();
   }
 }