|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
objectdraw.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.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ActiveObject()
Construct an ActiveObject. |
|
ActiveObject(java.lang.String name)
Constructs an ActiveObject with a given name. |
|
ActiveObject(java.lang.ThreadGroup group,
java.lang.Runnable target,
java.lang.String name)
Construct a new ActiveObject with the specified name using the Runnable and ThreadGroup parameters to determine its behavior. |
Method Summary | |
static void |
defer()
Deprecated. use ActiveObject.yield() instead |
static double |
getTime()
Deprecated. use System.currentTimeMillis() |
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. |
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, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ActiveObject()
public ActiveObject(java.lang.String name)
name
- the name of the new ActiveObject.public ActiveObject(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
group
- the thread group.target
- the object whose run method is called.name
- the name of the new ActiveObject.Method Detail |
public static void defer()
public static void yield()
public static void pause(long millis)
millis
- number of milliseconds to pause.public static void pause(double 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.public static double getTime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |