Top Description Fields Constructors Methods
java.util

pack-priv Class TimerThread

Located in compilation unit of java.util.Timer.

extends Thread
Class Inheritance

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

Modifier and TypeField and Description
pack-priv 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.

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
mainLoop()

The main timer loop.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

newTasksMayBeScheduledback to summary
pack-priv 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!

queueback to summary
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.

Constructor Detail

TimerThreadback to summary
pack-priv TimerThread(TaskQueue queue)

Method Detail

mainLoopback to summary
private void mainLoop()

The main timer loop. (See class comment.)

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.