net.i2p.util
Class SimpleTimer2

java.lang.Object
  extended by net.i2p.util.SimpleTimer2
Direct Known Subclasses:
RetransmissionTimer

public class SimpleTimer2
extends Object

Simple event scheduler - toss an event on the queue and it gets fired at the appropriate time. The method that is fired however should NOT block (otherwise they b0rk the timer). This rewrites the old SimpleTimer to use the java.util.concurrent.ScheduledThreadPoolExecutor. SimpleTimer has problems with lock contention; this should work a lot better. This supports cancelling and arbitrary rescheduling. If you don't need that, use SimpleScheduler instead. SimpleTimer is deprecated, use this or SimpleScheduler.

Author:
zzz

Nested Class Summary
static class SimpleTimer2.TimedEvent
          Similar to SimpleTimer.TimedEvent but users must extend instead of implement, and all schedule and cancel methods are through this class rather than SimpleTimer2.
 
Constructor Summary
  SimpleTimer2(I2PAppContext context)
          To be instantiated by the context.
protected SimpleTimer2(I2PAppContext context, String name)
          To be instantiated by the context.
protected SimpleTimer2(I2PAppContext context, String name, boolean prestartAllThreads)
          To be instantiated by the context.
 
Method Summary
static SimpleTimer2 getInstance()
          If you have a context, use context.simpleTimer2() instead
 void stop()
          Stops the SimpleTimer.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTimer2

public SimpleTimer2(I2PAppContext context)
To be instantiated by the context. Others should use context.simpleTimer2() instead


SimpleTimer2

protected SimpleTimer2(I2PAppContext context,
                       String name)
To be instantiated by the context. Others should use context.simpleTimer2() instead


SimpleTimer2

protected SimpleTimer2(I2PAppContext context,
                       String name,
                       boolean prestartAllThreads)
To be instantiated by the context. Others should use context.simpleTimer2() instead

Since:
0.9
Method Detail

getInstance

public static SimpleTimer2 getInstance()
If you have a context, use context.simpleTimer2() instead


stop

public void stop()
Stops the SimpleTimer. Subsequent executions should not throw a RejectedExecutionException.


toString

public String toString()
Overrides:
toString in class Object