Runnable
| Kind of class: | public interface |
|---|---|
| Package: | com.bourre.commands |
| Inherits from: | none |
| Author: | Cédric Néhémie |
| Classpath: | com.bourre.commands.Runnable |
| File last modified: | Wednesday, 16 January 2008, 10:03:16 |
Runnable interface should be implemented by anyclass whose instances are intended to be executed asynchronously.
The class must define a method of no arguments called
run.This interface is designed to provide a common protocol for objects
that wish to execute code while they are active. For example,Runnable is implemented by interface Tweenor ASyncCommand. Being active simply means that an
asynchronous process has been started and has not yet been stopped.
Concret implementations must take care that a process is considered
as running only if there is an active computation. More formally,
if the operation is paused, suspended (as defined by theSuspendable interface or any other interface), the
object is considered as not running.
To go further, and to make clear the differents reflections about
the run concept, I will detail the notion with the loading
example. We could consider that a loading is not running inasmuch
as the bytes loaded doesn't change since the last check. In that
approach we can make the timeout detection more accurate by not
esteem systematically that a slow loading is a failing loading.
The rules which defines the interruption clauses of a Runnableare not defined here. Sub-interfaces such Suspendable andCancelable provides methods to allow users to interrupt the
operation in slightly different ways.
There's no restriction about how concret classes implements or not
a notification of their process completion. More formally, there's
many possible ending for an asynchronous process, such failure, success
or user interruption, it is the reason why there's many interface which
extends the Runnable interface to define process ending rules.
Summary
Instance methods
isRunning
true if this object is running. -
trueif this object is running.
run
The contract for concret implementations of the run
method is that the Runnable object must be considered
as running as result of the call. Except if an exception was throw
during the call.
- {VISDOC_LINK_0}
IllegalStateException— if therunmethod have been called wheras the operation is currently
running. - {VISDOC_LINK_1}
IllegalStateException— if the object cannot
be run for any reasons.