Top Description Inners Fields Constructors Methods
org.hsqldb.lib

public final Class HsqlTimer

extends Object
implements Comparator, ThreadFactory
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.ThreadFactory, java.util.Comparator
Imports
java.util.Comparator, .Date

Facility to schedule tasks for future execution in a background thread.

Tasks may be scheduled for one-time execution or for repeated execution at regular intervals, using either fixed rate or fixed delay policy.

This class is a JDK 1.1 compatible implementation required by HSQLDB both because the java.util.Timer class is available only in JDK 1.3+ and because java.util.Timer starves least recently added tasks under high load and fixed rate scheduling, especially when the average actual task duration is greater than the average requested task periodicity.

An additional (minor) advantage over java.util.Timer is that this class does not retain a live background thread during periods when the task queue is empty.

Author
Campbell Burnet (campbell-burnet@users dot sourceforge.net)
Since
1.7.2
Version
1.9.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
HsqlTimer.Task

Encapsulates a Runnable and its scheduling attributes.

protected static class
HsqlTimer.TaskQueue

Heap-based priority queue.

protected class
HsqlTimer.TaskRunner

The Runnable that the background thread uses to execute scheduled tasks.

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
isShutdown

Whether this timer should disallow all further processing.

pack-priv static int
nowCount

stats var

pack-priv final HsqlTimer.TaskQueue
taskQueue

The priority queue for the scheduled tasks.

pack-priv final HsqlTimer.TaskRunner
taskRunner

The inner runnable that executes tasks in the background thread.

pack-priv Thread
taskRunnerThread

The background thread.

pack-priv final ThreadFactory
threadFactory

The factory that produces the background threads.

Constructor Summary

AccessConstructor and Description
public
HsqlTimer()

Constructs a new HsqlTimer using the default thread factory implementation.

public
HsqlTimer(final ThreadFactory
the ThreadFactory used to produce this timer's background threads. If null, the default implementation supplied by this class will be used.
threadFactory
)

Constructs a new HsqlTimer.

Method Summary

Modifier and TypeMethod and Description
pack-priv HsqlTimer.Task

Returns:

an opaque reference to the internal task
addTask
(final long
the time of the task's first execution
first
,
final Runnable
the Runnable to execute
runnable
,
final long
the task's periodicity
period
,
boolean
if true, use fixed rate else use fixed delay scheduling
relative
)

Adds to the task queue a new Task object encapsulating the supplied Runnable and scheduling arguments.

public static void
cancel(final Object
a task reference
task
)

Causes the task referenced by the supplied argument to be cancelled.

pack-priv synchronized void
clearThread()

Sets the background thread to null.

public int

Returns:

0 if equal, < 0 if a < b, > 0 if a > b
compare
(final Object
the first Task
a
,
final Object
the second Task
b
)

Implements java.util.Comparator.compare.

Required to back the priority queue for scheduled tasks.

public static Date

Returns:

the last time the referenced task was executed; null if never
getLastScheduled
(Object
a task reference
task
)

Retrieves the last time the referenced task was executed, as a Date object.

public static Date

Returns:

the next time the referenced task is due to be executed
getNextScheduled
(Object
a task reference
task
)

Retrieves the next time the referenced task is due to be executed, as a Date object.

public synchronized Thread

Returns:

the current background thread (may be null)
getThread
()

Retrieves the background execution thread.

public static boolean

Returns:

true if referenced task is cancelled
isCancelled
(final Object
a task reference
task
)

Retrieves whether the specified argument references a cancelled task.

public static boolean

Returns:

true if the reference is scheduled using a fixed delay
isFixedDelay
(final Object
a task reference
task
)

Retrieves whether the specified argument references a task scheduled periodically using fixed delay scheduling.

public static boolean

Returns:

true if the task is scheduled at a fixed rate
isFixedRate
(final Object
a task reference
task
)

Retrieves whether the specified argument references a task scheduled periodically using fixed rate scheduling.

public static boolean

Returns:

true if the task is scheduled for periodic execution
isPeriodic
(final Object
a task reference
task
)

Retrieves whether the specified argument references a task scheduled for periodic execution.

public Thread

Returns:

a new Thread constructed from the designated runnable.
newThread
(final Runnable
used to construct the new Thread.
runnable
)

Implements org.hsqldb.lib.ThreadFactory.newThread.

Default ThreadFactory implementation.

pack-priv HsqlTimer.Task

Returns:

the next task to execute, or null
nextTask
()

Retrieves the next task to execute, or null if this timer is shutdown, the current thread is interrupted, or there are no queued tasks.

pack-priv static long

Returns:

System.currentTimeMillis()
now
()

Convenience method replacing the longer incantation: System.currentTimeMillis()

public synchronized void
restart()

(Re)starts background processing of the task queue.

public Object

Returns:

opaque reference to the internal task
scheduleAfter
(final long
in milliseconds
delay
,
final Runnable
the Runnable to execute.
runnable
)

Causes the specified Runnable to be executed once in the background after the specified delay.

public Object

Returns:

opaque reference to the internal task
scheduleAt
(final Date
time at which to execute the specified Runnable
date
,
final Runnable
the Runnable to execute.
runnable
)

Causes the specified Runnable to be executed once in the background at the specified time.

public Object

Returns:

opaque reference to the internal task
schedulePeriodicallyAfter
(final long
in milliseconds
delay
,
final long
the cycle period
period
,
final Runnable
the Runnable to execute.
runnable
,
final boolean
if true, fixed rate scheduling else fixed delay scheduling
relative
)

Causes the specified Runnable to be executed periodically in the background, starting after the specified delay.

public Object

Returns:

opaque reference to the internal task
schedulePeriodicallyAt
(final Date
time at which to execute the specified Runnable
date
,
final long
the cycle period
period
,
final Runnable
the Runnable to execute
runnable
,
final boolean
if true, fixed rate scheduling else fixed delay scheduling
relative
)

Causes the specified Runnable to be executed periodically in the background, starting at the specified time.

public static Object

Returns:

a task reference, as per the rules stated above.
setPeriod
(final Object
the task whose periodicity is to be set
task
,
final long
the new period
period
)

Sets the periodicity of the designated task to a new value.

public synchronized void
shutdown()

Shuts down this timer after the current task (if any) completes.

public synchronized void
shutDown()

for compatibility with previous version

public synchronized void
shutdownImmediately()

Shuts down this timer immediately, interrupting the wait state associated with the current head of the task queue or the wait state internal to the currently executing task, if any such state is currently in effect.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isShutdownback to summary
pack-priv volatile boolean isShutdown

Whether this timer should disallow all further processing. Once set true, stays true forever.

nowCountback to summary
pack-priv static int nowCount

stats var

taskQueueback to summary
pack-priv final HsqlTimer.TaskQueue taskQueue

The priority queue for the scheduled tasks.

taskRunnerback to summary
pack-priv final HsqlTimer.TaskRunner taskRunner

The inner runnable that executes tasks in the background thread.

taskRunnerThreadback to summary
pack-priv Thread taskRunnerThread

The background thread.

threadFactoryback to summary
pack-priv final ThreadFactory threadFactory

The factory that produces the background threads.

Constructor Detail

HsqlTimerback to summary
public HsqlTimer()

Constructs a new HsqlTimer using the default thread factory implementation.

HsqlTimerback to summary
public HsqlTimer(final ThreadFactory threadFactory)

Constructs a new HsqlTimer. Uses the specified thread factory implementation.

Parameters
threadFactory:ThreadFactory

the ThreadFactory used to produce this timer's background threads. If null, the default implementation supplied by this class will be used.

Method Detail

addTaskback to summary
pack-priv HsqlTimer.Task addTask(final long first, final Runnable runnable, final long period, boolean relative)

Adds to the task queue a new Task object encapsulating the supplied Runnable and scheduling arguments.

Parameters
first:long

the time of the task's first execution

runnable:Runnable

the Runnable to execute

period:long

the task's periodicity

relative:boolean

if true, use fixed rate else use fixed delay scheduling

Returns:HsqlTimer.Task

an opaque reference to the internal task

cancelback to summary
public static void cancel(final Object task)

Causes the task referenced by the supplied argument to be cancelled. If the referenced task is currently executing, it will continue until finished but will not be rescheduled.

Parameters
task:Object

a task reference

clearThreadback to summary
pack-priv synchronized void clearThread()

Sets the background thread to null.

compareback to summary
public int compare(final Object a, final Object b)

Implements java.util.Comparator.compare.

Required to back the priority queue for scheduled tasks.

Parameters
a:Object

the first Task

b:Object

the second Task

Returns:int

0 if equal, < 0 if a < b, > 0 if a > b

getLastScheduledback to summary
public static Date getLastScheduled(Object task)

Retrieves the last time the referenced task was executed, as a Date object. If the task has never been executed, null is returned.

Parameters
task:Object

a task reference

Returns:Date

the last time the referenced task was executed; null if never

getNextScheduledback to summary
public static Date getNextScheduled(Object task)

Retrieves the next time the referenced task is due to be executed, as a Date object. If the referenced task is cancelled, null is returned.

Parameters
task:Object

a task reference

Returns:Date

the next time the referenced task is due to be executed

getThreadback to summary
public synchronized Thread getThread()

Retrieves the background execution thread.

null is returned if there is no such thread.

Returns:Thread

the current background thread (may be null)

isCancelledback to summary
public static boolean isCancelled(final Object task)

Retrieves whether the specified argument references a cancelled task.

Parameters
task:Object

a task reference

Returns:boolean

true if referenced task is cancelled

isFixedDelayback to summary
public static boolean isFixedDelay(final Object task)

Retrieves whether the specified argument references a task scheduled periodically using fixed delay scheduling.

Parameters
task:Object

a task reference

Returns:boolean

true if the reference is scheduled using a fixed delay

isFixedRateback to summary
public static boolean isFixedRate(final Object task)

Retrieves whether the specified argument references a task scheduled periodically using fixed rate scheduling.

Parameters
task:Object

a task reference

Returns:boolean

true if the task is scheduled at a fixed rate

isPeriodicback to summary
public static boolean isPeriodic(final Object task)

Retrieves whether the specified argument references a task scheduled for periodic execution.

Parameters
task:Object

a task reference

Returns:boolean

true if the task is scheduled for periodic execution

newThreadback to summary
public Thread newThread(final Runnable runnable)

Implements org.hsqldb.lib.ThreadFactory.newThread.

Default ThreadFactory implementation.

Constructs a new Thread from the designated runnable, sets its name to "HSQLDB Timer @" + Integer.toHexString(hashCode()), and sets it as a daemon thread.

Parameters
runnable:Runnable

used to construct the new Thread.

Returns:Thread

a new Thread constructed from the designated runnable.

nextTaskback to summary
pack-priv HsqlTimer.Task nextTask()

Retrieves the next task to execute, or null if this timer is shutdown, the current thread is interrupted, or there are no queued tasks.

Returns:HsqlTimer.Task

the next task to execute, or null

nowback to summary
pack-priv static long now()

Convenience method replacing the longer incantation: System.currentTimeMillis()

Returns:long

System.currentTimeMillis()

restartback to summary
public synchronized void restart() throws IllegalStateException

(Re)starts background processing of the task queue.

Exceptions
IllegalStateException:
if this timer is shut down.
See Also
shutdown(), shutdownImmediately()
scheduleAfterback to summary
public Object scheduleAfter(final long delay, final Runnable runnable) throws IllegalArgumentException

Causes the specified Runnable to be executed once in the background after the specified delay.

Parameters
delay:long

in milliseconds

runnable:Runnable

the Runnable to execute.

Returns:Object

opaque reference to the internal task

Exceptions
IllegalArgumentException:
if runnable is null
scheduleAtback to summary
public Object scheduleAt(final Date date, final Runnable runnable) throws IllegalArgumentException

Causes the specified Runnable to be executed once in the background at the specified time.

Parameters
date:Date

time at which to execute the specified Runnable

runnable:Runnable

the Runnable to execute.

Returns:Object

opaque reference to the internal task

Exceptions
IllegalArgumentException:
if date or runnable is null
schedulePeriodicallyAfterback to summary
public Object schedulePeriodicallyAfter(final long delay, final long period, final Runnable runnable, final boolean relative) throws IllegalArgumentException

Causes the specified Runnable to be executed periodically in the background, starting after the specified delay.

Parameters
delay:long

in milliseconds

period:long

the cycle period

runnable:Runnable

the Runnable to execute.

relative:boolean

if true, fixed rate scheduling else fixed delay scheduling

Returns:Object

opaque reference to the internal task

Exceptions
IllegalArgumentException:
if runnable is null or period is <= 0
schedulePeriodicallyAtback to summary
public Object schedulePeriodicallyAt(final Date date, final long period, final Runnable runnable, final boolean relative) throws IllegalArgumentException

Causes the specified Runnable to be executed periodically in the background, starting at the specified time.

Parameters
date:Date

time at which to execute the specified Runnable

period:long

the cycle period

runnable:Runnable

the Runnable to execute

relative:boolean

if true, fixed rate scheduling else fixed delay scheduling

Returns:Object

opaque reference to the internal task

Exceptions
IllegalArgumentException:
if date or runnable is null, or period is <= 0
setPeriodback to summary
public static Object setPeriod(final Object task, final long period)

Sets the periodicity of the designated task to a new value.

If the designated task is cancelled or the new period is identical to the task's current period, then this invocation has essentially no effect and the submitted object is returned.

Otherwise, if the new period is greater than the designated task's current period, then a simple assignment occurs and the submitted object is returned.

If neither case holds, then the designated task is cancelled and a new, equivalent task with the new period is scheduled for immediate first execution and returned to the caller.

Parameters
task:Object

the task whose periodicity is to be set

period:long

the new period

Returns:Object

a task reference, as per the rules stated above.

shutdownback to summary
public synchronized void shutdown()

Shuts down this timer after the current task (if any) completes.

After this call, the timer has permanently entered the shutdown state; attempting to schedule any new task or directly restart this timer will result in an IllegalStateException.

shutDownback to summary
public synchronized void shutDown()

for compatibility with previous version

shutdownImmediatelyback to summary
public synchronized void shutdownImmediately()

Shuts down this timer immediately, interrupting the wait state associated with the current head of the task queue or the wait state internal to the currently executing task, if any such state is currently in effect. After this call, the timer has permanently entered the shutdown state; attempting to schedule any new task or directly restart this timer will result in an IllegalStateException.

Note

If the integrity of work performed by a scheduled task may be adversely affected by an unplanned interruption, it is the responsibility of the task's implementation to deal correctly with the possibility that this method is called while such work is in progress, for instance by catching the InterruptedException, completing the work, and then rethrowing the exception.

org.hsqldb.lib back to summary

protected Class HsqlTimer.Task

extends Object
Class Inheritance

Encapsulates a Runnable and its scheduling attributes. Essentially, a wrapper class used to schedule a Runnable object for execution by the enclosing HsqlTimer's TaskRunner in a background thread.

Field Summary

Modifier and TypeField and Description
private final Object
cancel_mutex

Serializes concurrent access to the cancelled field.

pack-priv boolean
cancelled

Whether to silently remove this task instead of running it, the next time (if ever) it makes its way to the head of the timer queue.

pack-priv long
last

The time this task was last executed, or 0 if never.

pack-priv long
next

The next time this task is scheduled to execute.

pack-priv long
period

The periodic interval, or 0 if one-shot.

pack-priv final boolean
relative

Scheduling policy flag.

pack-priv Runnable
runnable

What to run.

Constructor Summary

AccessConstructor and Description
pack-priv
Task(final long
the first time to execute
first
,
final Runnable
the Runnable to execute
runnable
,
final long
the periodicity of execution
period
,
final boolean
if true, use fixed rate scheduling else fixed delay
relative
)

Constructs a new Task object encapsulating the specified Runnable and scheduling arguments.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
cancel()

Sets this task's cancelled flag true and signals its taskQueue.

pack-priv synchronized long

Returns:

the last time this task was executed or zero if never
getLastScheduled
()

Retrieves the instant in time just before this task was last executed by the background thread.

pack-priv synchronized long

Returns:

the time at which this task is next scheduled for execution
getNextScheduled
()

Retrieves the time at which this task is next scheduled for execution.

pack-priv boolean

Returns:

true if cancelled, else false
isCancelled
()

Retrieves whether this task is cancelled.

pack-priv synchronized Object

Returns:

a task reference, as per the rules stated above.
setPeriod
(final long
the new period
newPeriod
)

Sets the new periodicity of this task in milliseconds.

pack-priv synchronized void
updateSchedule(final long
when this task was last executed
last
,
final long
when this task is to be next executed
next
)

Updates the last and next scheduled execution times.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancel_mutexback to summary
private final Object cancel_mutex

Serializes concurrent access to the cancelled field.

cancelledback to summary
pack-priv boolean cancelled

Whether to silently remove this task instead of running it, the next time (if ever) it makes its way to the head of the timer queue.

lastback to summary
pack-priv long last

The time this task was last executed, or 0 if never.

nextback to summary
pack-priv long next

The next time this task is scheduled to execute.

periodback to summary
pack-priv long period

The periodic interval, or 0 if one-shot.

relativeback to summary
pack-priv final boolean relative

Scheduling policy flag.

When true, scheduling is fixed rate (as opposed to fixed delay), and schedule updates are calculated relative to when the task was last run rather than a fixed delay starting from the current wall-clock time provided by System.currentTimeMillis().

This helps normalize scheduling for tasks that must attempt to maintain a fixed rate of execution.

runnableback to summary
pack-priv Runnable runnable

What to run.

Constructor Detail

Taskback to summary
pack-priv Task(final long first, final Runnable runnable, final long period, final boolean relative)

Constructs a new Task object encapsulating the specified Runnable and scheduling arguments.

Parameters
first:long

the first time to execute

runnable:Runnable

the Runnable to execute

period:long

the periodicity of execution

relative:boolean

if true, use fixed rate scheduling else fixed delay

Method Detail

cancelback to summary
pack-priv void cancel()

Sets this task's cancelled flag true and signals its taskQueue.

getLastScheduledback to summary
pack-priv synchronized long getLastScheduled()

Retrieves the instant in time just before this task was last executed by the background thread. A value of zero indicates that this task has never been executed.

Returns:long

the last time this task was executed or zero if never

getNextScheduledback to summary
pack-priv synchronized long getNextScheduled()

Retrieves the time at which this task is next scheduled for execution.

Returns:long

the time at which this task is next scheduled for execution

isCancelledback to summary
pack-priv boolean isCancelled()

Retrieves whether this task is cancelled.

Returns:boolean

true if cancelled, else false

setPeriodback to summary
pack-priv synchronized Object setPeriod(final long newPeriod)

Sets the new periodicity of this task in milliseconds.

If this task is cancelled or the new period is identical to the current period, then this invocation has essentially no effect and this object is returned.

Otherwise, if the new period is greater than the current period, then a simple field assignment occurs and this object is returned.

If none of the previous cases hold, then this task is cancelled and a new, equivalent task with the new period is scheduled for immediate first execution and returned to the caller.

Parameters
newPeriod:long

the new period

Returns:Object

a task reference, as per the rules stated above.

updateScheduleback to summary
pack-priv synchronized void updateSchedule(final long last, final long next)

Updates the last and next scheduled execution times.

Parameters
last:long

when this task was last executed

next:long

when this task is to be next executed

org.hsqldb.lib back to summary

protected Class HsqlTimer.TaskQueue

extends HsqlArrayHeap<HsqlTimer.Task>
Class Inheritance

Heap-based priority queue. Provides extensions to facilitate and simplify implementing timer functionality.

Field Summary

Inherited from org.hsqldb.lib.HsqlArrayHeap:
countheapoc

Constructor Summary

AccessConstructor and Description
pack-priv
TaskQueue(final int
the initial capacity of the queue
capacity
,
final Comparator<HsqlTimer.Task>
The ObjectComparator this queue uses to maintain its Heap invariant.
oc
)

Constructs a new TaskQueue with the specified initial capacity and ObjectComparator.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addTask(final HsqlTimer.Task
the task to add
task
)

Type-safe add method.

pack-priv void
cancelAllTasks()

Atomically removes all tasks in this queue and then and cancels them.

pack-priv synchronized void
park(final long
the maximum time to wait in milliseconds.
timeout
)

Causes the calling thread to wait until another thread invokes unpark or the specified amount of time has elapsed.

pack-priv synchronized HsqlTimer.Task

Returns:

the earliest scheduled non-cancelled task, or null if no such task exists
peekTask
()

Retrieves the head of this queue, without removing it.

pack-priv HsqlTimer.Task

Returns:

this queue's head task or null if no such task exists
removeTask
()

Type-safe remove method.

pack-priv synchronized void
signalTaskCancelled(HsqlTimer.Task
a supposedly cancelled task
task
)

Informs this queue that the given task is supposedly cancelled.

pack-priv synchronized void
unpark()

Wakes up a single thread (if any) that is waiting on this queue's park method.

Inherited from org.hsqldb.lib.HsqlArrayHeap:
addclearisEmptyisFullpeekremovesizetoString

Constructor Detail

TaskQueueback to summary
pack-priv TaskQueue(final int capacity, final Comparator<HsqlTimer.Task> oc)

Constructs a new TaskQueue with the specified initial capacity and ObjectComparator.

Parameters
capacity:int

the initial capacity of the queue

oc:Comparator<HsqlTimer.Task>

The ObjectComparator this queue uses to maintain its Heap invariant.

Method Detail

addTaskback to summary
pack-priv void addTask(final HsqlTimer.Task task)

Type-safe add method.

Can be used to inject debugging or accounting behaviour.

Parameters
task:HsqlTimer.Task

the task to add

cancelAllTasksback to summary
pack-priv void cancelAllTasks()

Atomically removes all tasks in this queue and then and cancels them.

parkback to summary
pack-priv synchronized void park(final long timeout) throws InterruptedException

Causes the calling thread to wait until another thread invokes unpark or the specified amount of time has elapsed. Implements the sync and wait(n) half of this queue's availability condition.

Parameters
timeout:long

the maximum time to wait in milliseconds.

Exceptions
InterruptedException:
if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
peekTaskback to summary
pack-priv synchronized HsqlTimer.Task peekTask()

Retrieves the head of this queue, without removing it.

This method has the side effect of removing tasks from the head of this queue until a non-cancelled task is encountered or this queue is empty.

If this queue is initially empty or is emptied in the process of finding the earliest scheduled non-cancelled task, then null is returned.

Returns:HsqlTimer.Task

the earliest scheduled non-cancelled task, or null if no such task exists

removeTaskback to summary
pack-priv HsqlTimer.Task removeTask()

Type-safe remove method.

Removes the head task from this queue.

Can be used to inject debugging or accounting behaviour.

Returns:HsqlTimer.Task

this queue's head task or null if no such task exists

signalTaskCancelledback to summary
pack-priv synchronized void signalTaskCancelled(HsqlTimer.Task task)

Informs this queue that the given task is supposedly cancelled.

If the indicated task is identical to the current head of this queue, then it is removed and this queue is unparked.

The cancelled status of the given task is not verified; it is assumed that the caller is well-behaved (always passes a non-null reference to a cancelled task).

Parameters
task:HsqlTimer.Task

a supposedly cancelled task

unparkback to summary
pack-priv synchronized void unpark()

Wakes up a single thread (if any) that is waiting on this queue's park method. Implements the sync and notify half of this queue's availability condition.

org.hsqldb.lib back to summary

protected Class HsqlTimer.TaskRunner

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

The Runnable that the background thread uses to execute scheduled tasks.

Note

Outer class could simply implement Runnable, but using an inner class protects the public run method from potential abuse.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs the next available task in the background thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TaskRunnerback to summary
protected TaskRunner()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Runs the next available task in the background thread.

When there are no available tasks, the background thread dies and its instance field is cleared until tasks once again become available.