com.limegroup.gnutella.util
Class SimpleTimer

java.lang.Object
  extended bycom.limegroup.gnutella.util.SimpleTimer

public class SimpleTimer
extends java.lang.Object

A simplified replacement for java.util.Timer. Useful because java.util.Timer is not available in Java 1.1.8 (which we must use for the Mac).

Like Timer, this uses a single thread to service all tasks. Hence it assumes that timer tasks do not block for too long, and it doesn't provide real-time guarantees on scheduling.

Unlike Timer, it only support simple fixed-delay scheduling. Also it has no fancy provisions to clean up threads. It also notifies ActivityCallback of any uncaught exception while servicing tasks.


Constructor Summary
SimpleTimer(boolean isDaemon)
          Creates a new active SimpleTimer with a callback for internal errors.
 
Method Summary
 void cancel()
          Cancels this.
 void schedule(java.lang.Runnable task, long delay, long period)
          Schedules the given task for fixed-delay execution after the given delay, repeating every period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTimer

public SimpleTimer(boolean isDaemon)
Creates a new active SimpleTimer with a callback for internal errors.

Parameters:
isDaemon - true if this' thread should be a daemon.
Method Detail

schedule

public void schedule(java.lang.Runnable task,
                     long delay,
                     long period)
              throws java.lang.IllegalStateException
Schedules the given task for fixed-delay execution after the given delay, repeating every period.

Parameters:
task - the task to run repeatedly
delay - the initial delay, in milliseconds
period - the delay between executions, in milliseconds or zero if it should not be rescheduled
Throws:
java.lang.IllegalStateException - this is cancelled
java.lang.IllegalArgumentException - delay or period negative
See Also:
Timer.schedule(java.util.TimerTask,long,long)

cancel

public void cancel()
Cancels this. No more tasks can be scheduled or executed.