public static class ThreadPool.Singleton<T>
extends java.lang.Object
ThreadPool.SingletonResult
Modifier and Type | Field and Description |
---|---|
static int |
INFINITE_TIMEOUT |
Constructor and Description |
---|
Singleton() |
Modifier and Type | Method and Description |
---|---|
T |
await() |
T |
await(long ms)
Awaits the completion of the extant work item, if one exists
|
ThreadPool.SingletonResult<T> |
getResult()
Returns the result from the extant or previous work item, if any; otherwise, null.
|
void |
reset() |
void |
setService(java.util.concurrent.ExecutorService service) |
ThreadPool.SingletonResult<T> |
submit(java.util.concurrent.Callable<T> callable) |
ThreadPool.SingletonResult<T> |
submit(int msAwaitDefault,
java.util.concurrent.Callable<T> callable) |
ThreadPool.SingletonResult<T> |
submit(int msAwaitDefault,
java.lang.Runnable runnable)
Submits a runnable to the service of this singleton, but only if there's not some
other runnable currently submitted thereto.
|
ThreadPool.SingletonResult<T> |
submit(java.lang.Runnable runnable) |
public void setService(java.util.concurrent.ExecutorService service)
public void reset()
public ThreadPool.SingletonResult<T> submit(int msAwaitDefault, java.lang.Runnable runnable)
runnable
- the code to run if something's not already runningawait(long)
,
submit(int, Callable)
,
ThreadPool.SingletonResult.await(long)
public ThreadPool.SingletonResult<T> submit(java.lang.Runnable runnable)
public ThreadPool.SingletonResult<T> submit(int msAwaitDefault, java.util.concurrent.Callable<T> callable)
public ThreadPool.SingletonResult<T> submit(java.util.concurrent.Callable<T> callable)
public ThreadPool.SingletonResult<T> getResult()
public T await(long ms) throws java.lang.InterruptedException
java.lang.InterruptedException
getResult()
public T await() throws java.lang.InterruptedException
java.lang.InterruptedException