|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.sun.jini.thread.WakeupManager
A Queue of timed tasks. Each task implements Runnable.
Events can either be executed in the queue's thread or in their own thread.
A task is an object that implements Runnable. It is
scheduled by invoking schedule with a time at which it
should be run. When that time arrives (approximately) the task will
be pulled off the queue and have its run method invoked.
A schedule request can specify a
WakeupManager.ThreadDesc, which will define the parameters
of a thread to be created to run the Runnable. You can
specify the group, whether the thread is a daemon thread, and the priority.
When a tasks is scheduled a WakeupManager.Ticket is returned
that can be used to cancel the event if desired.
The queue requires its own thread, whose parameters can be defined
via a ThreadDesc if desired. This thread will
continue indefinitely until stop is called.
This class uses the Logger named
com.sun.jini.thread.WakeupManager to log information at
the following logging levels:
| Level | Description |
|---|---|
| INFO | exceptions thrown by the run methods of tasks |
| FINEST | how many milliseconds until the next task should be run |
Runnable| Nested Class Summary | |
static class |
WakeupManager.ThreadDesc
Description of a future thread. |
static class |
WakeupManager.Ticket
A ticket that can be used for cancelling a future task. |
| Field Summary |
| Fields inherited from interface com.sun.jini.constants.TimeConstants |
DAYS, HOURS, MINUTES, SECONDS |
| Constructor Summary | |
WakeupManager()
Create a new WakeupManager. |
|
WakeupManager(WakeupManager.ThreadDesc desc)
Create a new WakeupManager. |
|
| Method Summary | |
void |
cancel(WakeupManager.Ticket t)
Cancel the given ticket. |
void |
cancelAll()
Cancel all tickets. |
boolean |
isEmpty()
Return whether the queue is currently empty. |
WakeupManager.Ticket |
schedule(long when,
Runnable task)
Schedule the given task for the given time. |
WakeupManager.Ticket |
schedule(long when,
Runnable task,
WakeupManager.ThreadDesc threadDesc)
Schedule the given task for the given time, to be run in a thread. |
void |
stop()
Stop executing. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public WakeupManager()
WakeupManager. Equivalent to.
WakeupManager(new ThreadDesc())
WakeupManager.ThreadDescpublic WakeupManager(WakeupManager.ThreadDesc desc)
WakeupManager. The thread used for
timing will be created according to the provided ThreadDesc.
| Method Detail |
public WakeupManager.Ticket schedule(long when,
Runnable task)
run
method will be executed synchronously in the queue's own thread, so it
should be brief or it will affect whether future events will be executed
at an appropriate time.
public WakeupManager.Ticket schedule(long when,
Runnable task,
WakeupManager.ThreadDesc threadDesc)
ThreadDesc object provided. If threadDesc is
null, this is equivalent to the other form of
schedule.
public void cancel(WakeupManager.Ticket t)
public void cancelAll()
public boolean isEmpty()
public void stop()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||