java.util
Class TimerThread
java.lang.Object
|
+--java.lang.Thread
|
+--java.util.TimerThread
- All Implemented Interfaces:
- Runnable
- class TimerThread
- extends Thread
This "helper class" implements the timer's task execution thread, which
waits for tasks on the timer queue, executions them when they fire,
reschedules repeating tasks, and removes cancelled tasks and spent
non-repeating tasks from the queue.
Field Summary |
(package private) boolean |
newTasksMayBeScheduled
This flag is set to false by the reaper to inform us that there
are no more live references to our Timer object. |
private TaskQueue |
queue
Our Timer's queue. |
Method Summary |
private void |
mainLoop()
The main timer loop. |
void |
run()
Enabled: If this thread was constructed using a separate
Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns. |
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, start, stop, stop, suspend, toString, yield |
newTasksMayBeScheduled
boolean newTasksMayBeScheduled
- This flag is set to false by the reaper to inform us that there
are no more live references to our Timer object. Once this flag
is true and there are no more tasks in our queue, there is no
work left for us to do, so we terminate gracefully. Note that
this field is protected by queue's monitor!
queue
private TaskQueue queue
- Our Timer's queue. We store this reference in preference to
a reference to the Timer so the reference graph remains acyclic.
Otherwise, the Timer would never be garbage-collected and this
thread would never go away.
TimerThread
TimerThread(TaskQueue queue)
run
public void run()
- Description copied from class:
Thread
- Enabled: If this thread was constructed using a separate
Runnable
run object, then that
Runnable
object's run
method is called;
otherwise, this method does nothing and returns.
Subclasses of Thread
should override this method.
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
- See Also:
java.lang.Thread#start()
,
java.lang.Thread#stop()
,
java.lang.Thread#Thread(java.lang.ThreadGroup,
java.lang.Runnable, java.lang.String)
,
java.lang.Runnable#run()
mainLoop
private void mainLoop()
- The main timer loop. (See class comment.)
comments?