| org.cougaar.core.thread.Schedulable
All known Subclasses: org.cougaar.core.thread.TrivialSchedulable, org.cougaar.core.thread.SchedulableObject,
Schedulable | public interface Schedulable (Code) | | A Schedulable is an API provided by the
org.cougaar.core.service.ThreadService that takes the place
of standard Java
java.lang.Thread s and
java.util.TimerTask s.
Aside from a few special internal cases, all Threads and Tasks in
Cougaar should come from the ThreadService in the form of
Schedulables. To treat a Schedulable like a Thread, use the start
method. To treat a Schedulable like a TimerTask, use the schedule
methods. The ThreadService is the only source of usable
Schedulables.
|
Inner Class :interface SuspendCallback | |
Method Summary | |
boolean | cancel() Cancelling a Schedulable will prevent starting if it's
currently queued or from restarting if it was scheduled to do
so. | void | cancelTimer() | String | getBlockingExcuse() | int | getBlockingType() | Object | getConsumer() Returns the requestor for whom the ThreadService made this
Schedulable. | int | getLane() | String | getName() | int | getState() Returns the current state of the Schedulable. | long | getTimestamp() | void | resume() | void | schedule(long delay) The following methods behave more or less as they on
TimerTasks, except that the schedule methods can be called more
than once. | void | schedule(long delay, long interval) | void | scheduleAtFixedRate(long delay, long interval) | void | start() Starting a Schedulable is conceptually the same as starting a
Java Thread.
Note these differences: -
The
java.lang.Runnable.run method invoked due to the
Schedulable.start() should return promptly, to free the pooled
Thread for use by other waiting Schedulables.
-
If no thread resources are available, the Schedulable
will be queued instead of running right away.
| void | suspend(SuspendCallback callback) Like
Schedulable.cancel but with two differences: the Schedulable
can be resumed later, and a special callback is invoked when
the current run finishes. |
cancel | boolean cancel()(Code) | | Cancelling a Schedulable will prevent starting if it's
currently queued or from restarting if it was scheduled to do
so. It will not cancel the current run.
|
cancelTimer | void cancelTimer()(Code) | | |
getBlockingType | int getBlockingType()(Code) | | |
getConsumer | Object getConsumer()(Code) | | Returns the requestor for whom the ThreadService made this
Schedulable.
|
getLane | int getLane()(Code) | | Lane
|
getState | int getState()(Code) | | Returns the current state of the Schedulable. The states are
described in
CougaarThread .
|
getTimestamp | long getTimestamp()(Code) | | Other status methods, for the ThreadStatusService
|
resume | void resume()(Code) | | Restart after a
#suspend). |
schedule | void schedule(long delay)(Code) | | The following methods behave more or less as they on
TimerTasks, except that the schedule methods can be called more
than once. In that case, later calls effectively reschedule
the Schedulable. Since 'cancel' was already in use, a new
method had to be introduced to cancel a scheduled task. Thus
'cancelTimer'.
|
schedule | void schedule(long delay, long interval)(Code) | | |
scheduleAtFixedRate | void scheduleAtFixedRate(long delay, long interval)(Code) | | |
start | void start()(Code) | | Starting a Schedulable is conceptually the same as starting a
Java Thread.
Note these differences: -
The
java.lang.Runnable.run method invoked due to the
Schedulable.start() should return promptly, to free the pooled
Thread for use by other waiting Schedulables.
-
If no thread resources are available, the Schedulable
will be queued instead of running right away. It will only
run when enough resources have become available for it to
reach the head of the queue.
-
If the Schedulable is running at the time of the
call, it will restart itself after the current run finishes
(unless it's cancelled in the meantime). The
java.lang.Runnable.run called by
Schedulable.start() is
single-threaded.
|
suspend | void suspend(SuspendCallback callback)(Code) | | Like
Schedulable.cancel but with two differences: the Schedulable
can be resumed later, and a special callback is invoked when
the current run finishes.
|
|
|