|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.commons.concurrent.Executor
public class Executor
The Executor
is deegree's central place to:
The Executor
class is realized as a singleton and uses a cached thread pool internally to minimize
overhead for acquiring the necessary Thread
instances and to manage the number of concurrent threads.
ExecutorService
,
ExecutionFinishedListener
Method Summary | ||
---|---|---|
static Executor |
getInstance()
Returns the only instance of this class (singleton pattern). |
|
|
performAsynchronously(Callable<T> task,
ExecutionFinishedListener<T> finishedListener)
Performs a task asynchronously (in an independent thread) without any time limit. |
|
|
performAsynchronously(Callable<T> task,
ExecutionFinishedListener<T> finishedListener,
long timeout)
Performs a task asynchronously (in an independent thread) with a given time limit. |
|
|
performSynchronously(Callable<T> task,
long timeout)
Performs a task synchronously with a given timeout. |
|
|
performSynchronously(List<Callable<T>> tasks)
Performs several tasks synchronously in parallel threads. |
|
|
performSynchronously(List<Callable<T>> tasks,
long timeout)
Performs several tasks synchronously with a given timeout in parallel threads. |
|
void |
shutdown()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Executor getInstance()
public <T> void performAsynchronously(Callable<T> task, ExecutionFinishedListener<T> finishedListener)
T
- type of return valuetask
- task to be performed (specified in the Callable.call()
method)finishedListener
- notified when the method call finishes (succesfully or abnormally), may be nullpublic <T> void performAsynchronously(Callable<T> task, ExecutionFinishedListener<T> finishedListener, long timeout)
T
- type of return valuetask
- task to be performed (specified in the Callable.call()
method)finishedListener
- notified when the method call finishes (succesfully or abnormally), may be nulltimeout
- maximum time allowed for execution in millisecondspublic <T> T performSynchronously(Callable<T> task, long timeout) throws CancellationException, InterruptedException, Throwable
T
- type of return valuetask
- tasks to be performed (specified in the Callable.call()
method)timeout
- maximum time allowed for execution in milliseconds
CancellationException
- if the execution time exceeds the specified timeout / thread has been cancelled
InterruptedException
- if interrupted while waiting, in which case unfinished tasks are cancelled
Throwable
- if the tasks throws an exception itselfpublic <T> List<ExecutionFinishedEvent<T>> performSynchronously(List<Callable<T>> tasks) throws InterruptedException
This method does not return before all tasks are finished (successfully or abnormally). For each given
Callable
, an independent thread is used. For each task, an ExecutionFinishedEvent
is generated
and returned.
T
- the result type of the callablestasks
- tasks to be performed (specified in the Callable.call()
methods)
InterruptedException
- if the current thread was interrupted while waitingpublic <T> List<ExecutionFinishedEvent<T>> performSynchronously(List<Callable<T>> tasks, long timeout) throws InterruptedException
This method does not return before all tasks are finished (successfully or abnormally). For each given
Callable
, an independent thread is used. For each task, an ExecutionFinishedEvent
is generated
and returned.
T
- the result type of the taskstasks
- tasks to be performed (specified in the Callable.call()
methods)timeout
- maximum time allowed for execution (in milliseconds)
InterruptedException
- if the current thread was interrupted while waitingpublic void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |