- Starting a
Schedulable is conceptually the same as starting a Java native thread, but the behavior is slightly different in two ways. First, if no thread resources are available, the
Schedulable will be queued instead of running righy away. It will only run when enough resources have become available for it to reach the head of the queue. Second, if the
Schedulable is running at the time of the call, this call will cause the
Schedulable restart itself after the current run finishes (unless it’s cancelled in the meantime). If the Schedulable is pending at the time of the call, this method is a no-op.
void schedule(long delay)
- Equivalent to calling
start()after the given delay (in millis).
void schedule(long delay, long period)
- Runs a
Schedulable periodically at the period given, where each run is equivalent to
start()(ie it may not start immediately). The delay applies to the first run.
void scheduleAtFixedRate(long delay, long period)
- This is to the method above as the method by the same name on
TimerTask is to the
schedule method on that class (see Sun’s TimerTask javadoc).
- This method cancels the active periodic schedule. It does not cancel the
Schedulable entirely (see
- Cancelling a
Schedulable will prevent it starting if it’s currently queued or from restarting if it was scheduled to do so. It will not cancel the current run. This method also runs
- Returns the current state of the
Schedulable. The states are defined in org.cougaar.core.thread.CougaarThread and consist of the following:
- THREAD_PENDING (ie queued)
- THREAD_DISQUALIFIED (see thread disqualification)
- THREAD_DORMANT (ie none of the above)
- THREAD_SUSPENDED (not currently used)
- Returns the COUGAAR entity for which the
ThreadService made this
Schedulable. See thread creation.
- Returns the lane that this
Schedulable was assigned to. See thread creation. Lane constants can be found in the ThreadService interface.