org.jboss.util.timeout
public class: TimeoutFactory [javadoc |
source]
java.lang.Object
org.jboss.util.timeout.TimeoutFactory
The timeout factory.
This is written with performance in mind. In case of
n
active timeouts, creating, cancelling and firing timeouts all operate
in time
O(log(n)).
If a timeout is cancelled, the timeout is not discarded. Instead the
timeout is saved to be reused for another timeout. This means that if
no timeouts are fired, this class will eventually operate without
allocating anything on the heap.
- author:
< - a href="osh@sparre.dk">Ole Husgaard
- version:
$ - Revision: 1.1 $
| Method from org.jboss.util.timeout.TimeoutFactory Summary: |
|---|
|
createTimeout |
| Method from org.jboss.util.timeout.TimeoutFactory Detail: |
public static Timeout createTimeout(long time,
TimeoutTarget target) {
singleton = new TimeoutFactory();
Thread thread = new Thread() {
public void run() {
singleton.doWork();
}
};
thread.setDaemon(true);
thread.start();
if (time < = 0)
throw new IllegalArgumentException("Time not positive");
if (target == null)
throw new IllegalArgumentException("Null target");
return singleton.newTimeout(time, target);
}
|