/** {@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; } } }
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); } } }