This class provides a framework of simple hooks to run critical code on the main thread
for code that is running off the main thread.
The main operations for code that uses this class are invokeNow and invokeLater, and
the main operations for code that implements this class are the abstract methods,
and the configuration methods.
protected ThreadPump(int minHoldTime,
Creates a new ThreadPump object. All times are in milliseconds.
minHoldTime - The minimum amount of time to wait for the next operation
before giving up control of the main thread again. This should be set to 0 if
there is no or negligible penalty for regaining the main thread once given
maxHoldTime - The max time that the main thread should be monopolized
before it is given up. This is useful to prevent starvation.
waitTime - The amount of time to wait before resuming if the maxHoldTime
was met, and thread control was returned.
public void start()
Starts a transaction. This resets all the mechanisms for wait times.
For each start() call, there must be exactly one stop() call, however,
they may be called multiple times, and only when the last stop() is called
will it actually take effect.
public void stop()
Stops a transaction, and immediately returns control to the main thread, if
this is the last stop() method to be called.
Runs a task on the main thread and waits for it to complete. Tasks
submitted are queued up in order, so the task may not get run immediately,
and the task completion time is still dependant on the thread starvation