## org.das2.system.RequestProcessor

Utility class for synchronous execution. This class maintains a pool of threads that are used to execute arbitrary code. This class also serves as a central place to catch and handle unchecked exceptions. The {@link #invokeLater(java.lang.Runnable)} method is similar to the SwingUtilities {@link javax.swing.SwingUtilities#invokeLater(java.lang.Runnable)} method, except that the request is not executed on the event thread. The {@link #invokeLater(java.lang.Runnable, java.lang.Object)}, the {@link #invokeAfter(java.lang.Runnable, java.lang.Object)}, and the {@link #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 {@link #waitFor(java.lang.Object)} method will cause the calling thread to block until all requests with the specified lock finish.

## invokeAfter

invokeAfter( java.lang.Runnable run, Object lock ) → void

Executes run.run() asynchronously on a thread from the thread pool. The task will not be executed until after all requests made with {@link #invokeAfter(java.lang.Runnable, java.lang.Object)} or {@link #invokeLater(java.lang.Runnable, java.lang.Object)} with the same lock have finished.

### Parameters

run - the task to be executed.
lock - associates run with other tasks.

### Returns:

void (returns nothing)

### See Also:

waitFor(java.lang.Object)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## invokeLater

invokeLater( java.lang.Runnable run ) → void

Executes run.run() asynchronously on a thread from the thread pool.

### Parameters

run - the task to be executed.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## invokeLater

invokeLater( java.lang.Runnable run, Object lock ) → void

Executes run.run() asynchronously on a thread from the thread pool. The task will not be executed until after all requests made with {@link #invokeAfter(java.lang.Runnable, java.lang.Object)} with the same lock have finished.

### Parameters

run - the task to be executed.
lock - associates run with other tasks.

### Returns:

void (returns nothing)

### See Also:

waitFor(java.lang.Object)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## printStatus

printStatus( ) → void

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## setThreadCount

setThreadCount( int t ) → void

reset the maximum number of threads used. If there are more threads existing already, than the extra threads will be shut down as they finish their current jobs.

### Parameters

t - an int

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## shutdown

shutdown( ) → void

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## waitFor

waitFor( Object lock ) → void

Blocks until all tasks with the same lock have finished.

### Parameters

lock - an Object

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]