protected void startUpdateTimer() { Timer currentTimer = updateTimer.get(); if (currentTimer != null && currentTimer.isRunning()) { return; } if (DownloadWatchDog.getInstance().isRunning() == false) { return; } currentTimer = new Timer( 1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!(e.getSource() instanceof Timer)) { return; } if (e.getSource() != updateTimer.get() || !isDisplayable()) { Timer timer = ((Timer) e.getSource()); updateTimer.compareAndSet(timer, null); timer.stop(); return; } fastDelayer.run(); } }); currentTimer.setRepeats(true); updateTimer.set(currentTimer); currentTimer.start(); }
protected void stopUpdateTimer() { Timer old = updateTimer.getAndSet(null); if (old != null) { old.stop(); } }