public final class RequestProcessor
extends java.lang.Object
invokeLater(java.lang.Runnable)
method is similar to the
SwingUtilities SwingUtilities.invokeLater(java.lang.Runnable)
method, except that the request is not executed on the event thread.
The invokeLater(java.lang.Runnable, java.lang.Object)
,
the invokeAfter(java.lang.Runnable, java.lang.Object)
,
and the waitFor(java.lang.Object)
methods are designed to work
together. Both of the first two methods execute code asynchronously with
respect to the calling thread. Multiple requests made with a call to
invokeLater that specified the same lock can execute at the same time,
but not while a request made with the invokeAfter with the same lock
is processing. Any requests made before an invokeAfter request with the
same lock will finish before that invokeAfter request begins. An
invokeAfter request will finish before any requests with the same lock made
after that invokeAfter request begins. The waitFor(java.lang.Object)
method will cause the calling thread to block until all requests with the
specified lock finish.Modifier and Type | Method and Description |
---|---|
static void |
invokeAfter(java.lang.Runnable run,
java.lang.Object lock)
Executes run.run() asynchronously on a thread from the thread pool.
|
static void |
invokeLater(java.lang.Runnable run)
Executes run.run() asynchronously on a thread from the thread pool.
|
static void |
invokeLater(java.lang.Runnable run,
java.lang.Object lock)
Executes run.run() asynchronously on a thread from the thread pool.
|
static void |
printStatus() |
static void |
setThreadCount(int t)
reset the maximum number of threads used.
|
static void |
shutdown() |
static void |
waitFor(java.lang.Object lock)
Blocks until all tasks with the same lock have finished.
|
public static void printStatus()
public static void invokeLater(java.lang.Runnable run)
run
- the task to be executed.public static void setThreadCount(int t)
t
- public static void invokeLater(java.lang.Runnable run, java.lang.Object lock)
invokeAfter(java.lang.Runnable, java.lang.Object)
with the same
lock have finished.run
- the task to be executed.lock
- associates run with other tasks.waitFor(java.lang.Object)
public static void invokeAfter(java.lang.Runnable run, java.lang.Object lock)
invokeAfter(java.lang.Runnable, java.lang.Object)
or
invokeLater(java.lang.Runnable, java.lang.Object)
with the same
lock have finished.run
- the task to be executed.lock
- associates run with other tasks.waitFor(java.lang.Object)
public static void waitFor(java.lang.Object lock) throws java.lang.InterruptedException
lock
- java.lang.InterruptedException
- if the current thread is
interrupted while waiting.public static void shutdown()