|
Scribble Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread cs101.lang.AnimatorThread
This class replaces Thread as a way to animate autonomous objects. An AnimatorThread can be passed any object that implements the Animate interface. The AnimatorThread (when started) begins executing at the Animate's act() method. Instances of this class provide safe ways to start, stop, suspend, and resume execution through the use of startExecution(), stopExecution(), suspendExecution() and resumeExecution() methods. Unlike java.lang.Thread, this class cannot be extended. Copyright 1999 Massachusetts Institute of Technology
Thread
,
Animate
,
startExecution()
,
stopExecution()
,
suspendExecution()
,
resumeExecution()
Field Summary | |
static boolean |
DONT_START_YET
These constants allow mnemonic access to AnimateObject's final constructor argument, i.e., should the object start running on construction or on (a subsequent) call to a separate start() method? |
static boolean |
START_IMMEDIATELY
These constants allow mnemonic access to AnimateObject's final constructor argument, i.e., should the object start running on construction or on (a subsequent) call to a separate start() method? |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
AnimatorThread(Animate a)
This constructor requires the Animate that is to be animated. |
|
AnimatorThread(Animate a,
boolean startImmediately)
This constructor requires the Animate that is to be animated and a boolean value (expected to be one of AnimatorThread.START_IMMEDIATELY or AnimatorThread.DONT_START_YET) that determines whether this AnimatorThread should start running as the last step of its construction. |
|
AnimatorThread(Animate a,
boolean startImmediately,
long sleepRange)
This constructor requires the Animate that is to be animated, a boolean reflecting whether execution should begin immediately, and a long representing the desired variance in sleep times between calls to the Animate's act() method. |
|
AnimatorThread(Animate a,
boolean startImmediately,
long sleepRange,
long sleepMinInterval)
This constructor requires the Animate that is to be animated, a boolean reflecting whether execution should begin immediately, and two longs representing the desired variance in sleep times and the desired minimum sleep interval between calls to the Animate's act() method. |
|
AnimatorThread(Animate a,
long sleepRange)
This constructor requires the Animate that is to be animated and a long representing the desired variance in sleep times between calls to the Animate's act() method. |
|
AnimatorThread(Animate a,
long sleepRange,
long sleepMinInterval)
This constructor requires the Animate that is to be animated and two longs representing the desired variance in sleep times and the desired minimum sleep interval between calls to the Animate's act() method. |
Method Summary | |
void |
resumeExecution()
Resumes execution after a temporary suspension (using suspendExecution()). |
void |
run()
Repeatedly invoke your Animate's act() method, sleeping between invocations. |
void |
setSleepMinInterval(long minInterval)
Gives access to this AnimatorThread's sleep minimum. |
void |
setSleepRange(long range)
This controls the possible range of durations for AnimatorThread to sleep, i.e., the possible time between actions for the Animate that it animates. |
void |
start()
Begin execution. |
void |
startExecution()
Begin execution. |
void |
stopExecution()
Terminates execution. |
void |
suspendExecution()
Temporarily suspends execution. |
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, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final boolean START_IMMEDIATELY
AnimatorThread( Animate, boolean )
,
Constant Field Valuespublic static final boolean DONT_START_YET
AnimatorThread( Animate, boolean )
,
Constant Field ValuesConstructor Detail |
public AnimatorThread(Animate a)
a
- the Animate to be animated.Animate
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
public AnimatorThread(Animate a, boolean startImmediately)
a
- the Animate to be animated.startImmediately
- one of AnimatorThread.START_IMMEDIATELY
or AnimatorThread.DONT_START_YETAnimate
,
AnimatorThread( Animate )
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
public AnimatorThread(Animate a, long sleepRange)
a
- the Animate to be animated.sleepRange
- the desired variance in sleep times above and
beyond sleepMinIntervalAnimate
,
AnimatorThread( Animate )
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
public AnimatorThread(Animate a, boolean startImmediately, long sleepRange)
a
- the Animate to be animated.startImmediately
- one of AnimatorThread.START_IMMEDIATELY
or AnimatorThread.DONT_START_YETsleepRange
- the desired variance in sleep times above and
beyond sleepMinIntervalAnimate
,
AnimatorThread( Animate, boolean )
,
AnimatorThread( Animate, long )
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
public AnimatorThread(Animate a, long sleepRange, long sleepMinInterval)
a
- the Animate to be animated.sleepRange
- the desired variance in sleep times above and
beyond sleepMinIntervalsleepMinInterval
- the minimum interval between calls to
the Animate's act() methodAnimate
,
AnimatorThread( Animate )
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
public AnimatorThread(Animate a, boolean startImmediately, long sleepRange, long sleepMinInterval)
a
- the Animate to be animated.startImmediately
- one of AnimatorThread.START_IMMEDIATELY
or AnimatorThread.DONT_START_YETsleepRange
- the desired variance in sleep times above and
beyond sleepMinIntervalsleepMinInterval
- the minimum interval between calls to
the Animate's act() methodAnimate
,
AnimatorThread( Animate, boolean )
,
AnimatorThread( Animate, long, long )
,
start()
,
setSleepMinInterval(long)
,
setSleepRange( long )
Method Detail |
public void run()
Animate
,
setSleepMinInterval(long)
,
setSleepRange( long )
public void start()
Animate
,
AnimatorThread(Animate)
,
Thread.start()
public void startExecution()
Animate
,
AnimatorThread(Animate)
,
Thread.start()
public void stopExecution()
Thread.stop()
public void suspendExecution()
resumeExecution()
,
Thread.suspend()
public void resumeExecution()
suspendExecution()
,
Thread.resume()
public void setSleepMinInterval(long minInterval)
AnimatorThread( Animate, boolean, long, long )
,
setSleepRange( long )
public void setSleepRange(long range)
AnimatorThread( Animate, boolean, long, long )
,
setSleepRange( long )
|
Scribble Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |