|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
objectdraw.ActiveObject
public class ActiveObject
The class ActiveObject is used to define objects controlled by sequences of instructions that are executed independently of and simultaneously with other instructions in a program. The code that is to be executed independently should be placed in the body of a parameterless run method defined within a class definition that extends ActiveObject. When the start() method of an ActiveObject is invoked, the system will being to execute whatever code was placed in this run method.
ActiveObject is a simple extension of Java's native Thread class. ActiveObjects are automatically managed so that they are suspended and restarted when an applet is stopped and started. In addition, the sleep method provided in the Thread class is replaced with a similar pause method that does not require exception handling.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ActiveObject()
Construct an ActiveObject. |
|
ActiveObject(String name)
Constructs an ActiveObject with a given name. |
|
ActiveObject(ThreadGroup group,
Runnable target,
String name)
Construct a new ActiveObject with the specified name using the Runnable and ThreadGroup parameters to determine its behavior. |
Method Summary | |
---|---|
(package private) static void |
initializeEventList()
Initializes the event list that handles threads |
(package private) static void |
introspect()
The ActiveObject calling introspect calls the execute methods of the ActiveObjectEventInterface events it has been scheduled to call by calls to scheduleEvent and scheduleClassEvent. |
static void |
pause(double millis)
Suspend the execution of this ActiveObject for at least the time period specified. |
static void |
pause(long millis)
Suspend the execution of this ActiveObject for at least the time period specified. |
static void |
pause(long millis,
int nano)
Suspend the execution of this ActiveObject for at least the time period specified. |
(package private) static void |
scheduleClassEvent(ActiveObjectEventInterface event)
Schedules event's execute method to be called once by all ActiveObjects not yet dead, including those yet to be created. |
(package private) void |
scheduleEvent(ActiveObjectEventInterface event)
Schedules event's execute method to be called once by this ActiveObject. |
static void |
yield()
Briefly suspend the execution of this ActiveObject code to see if any other ActiveObject or Thread is waiting to execute. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ActiveObject()
public ActiveObject(String name)
name
- the name of the new ActiveObject.public ActiveObject(ThreadGroup group, Runnable target, String name)
group
- the thread group.target
- the object whose run method is called.name
- the name of the new ActiveObject.Method Detail |
---|
static void initializeEventList()
static void introspect()
public static void pause(double millis)
millis
- number of milliseconds to pause.public static void pause(long millis)
millis
- number of milliseconds to pause.public static void pause(long millis, int nano)
millis
- number of milliseconds to pause.nano
- additional number of nanoseconds to pause.static void scheduleClassEvent(ActiveObjectEventInterface event)
event
- event scheduled to be executed once by this ActiveObject.void scheduleEvent(ActiveObjectEventInterface event)
event
- event scheduled to be executed once by this ActiveObject.public static void yield()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |