コード例 #1
0
 /** {@inheritDoc} */
 public void removeHostListener(HostListener listener) {
   /*
    * XXX: if a disconnect method is added, make sure it calls
    * this method to unregister this object from the watcher. otherwise,
    * an unused MonitoredHostProvider instance may go uncollected.
    */
   synchronized (listeners) {
     listeners.remove(listener);
     if (listeners.isEmpty() && (task != null)) {
       task.cancel();
       task = null;
     }
   }
 }
コード例 #2
0
  public void setInterval(int newInterval) {
    synchronized (listeners) {
      if (newInterval == interval) {
        return;
      }

      int oldInterval = interval;
      super.setInterval(newInterval);

      if (task != null) {
        task.cancel();
        NotifierTask oldTask = task;
        task = new NotifierTask();
        CountedTimerTaskUtils.reschedule(timer, oldTask, task, oldInterval, newInterval);
      }
    }
  }