Methods Summary |
---|
public void | addTimerListener(TimerListener listener)
listeners.add( listener );
|
void | fireEvent()
for ( TimerListener listener : listeners )
listener.timerFired( new TimerEvent(this) );
|
public long | getDelay() return this.delay;
|
public boolean | isRunning() return !stopped;
|
public void | removeTimerListener(TimerListener listener)
listeners.remove( listener );
|
public void | run()
while( !stopped )
{
fireEvent();
try {
Thread.sleep( delay );
} catch ( InterruptedException e ) {
return; // die
}
}
|
public void | setDelay(long delay) this.delay = delay;
|
public void | setRunning(boolean b)
if ( b )
start();
else
stop();
|
public synchronized void | start()
if ( stopped )
{
stopped = false;
thread = new Thread(this);
thread.start();
}
|
public synchronized void | stop()
if ( !stopped )
{
stopped = true;
if ( thread != null )
thread.interrupt();
}
|