deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.framework.concurrent
Class Executor

java.lang.Object
  extended by org.deegree.framework.concurrent.Executor

public class Executor
extends java.lang.Object

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.

Version:
$Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
Author:
Andreas Poth, Andreas Schmitz, Rutger Bezema, Markus Schneider, last edited by: $Author: mschneider $
See Also:
ExecutorService, ExecutionFinishedListener

Method Summary
static Executor getInstance()
          Returns the only instance of this class (singleton pattern).
<T> void
performAsynchronously(java.util.concurrent.Callable<T> task, ExecutionFinishedListener<T> finishedListener)
          Performs a task asynchronously (in an independent thread) without any time limit.
<T> void
performAsynchronously(java.util.concurrent.Callable<T> task, ExecutionFinishedListener<T> finishedListener, long timeout)
          Performs a task asynchronously (in an independent thread) with a given time limit.
<T> T
performSynchronously(java.util.concurrent.Callable<T> task, long timeout)
          Performs a task synchronously with a given timeout.
<T> java.util.List<ExecutionFinishedEvent<T>>
performSynchronously(java.util.List<java.util.concurrent.Callable<T>> tasks)
          Performs several tasks synchronously in parallel threads.
<T> java.util.List<ExecutionFinishedEvent<T>>
performSynchronously(java.util.List<java.util.concurrent.Callable<T>> tasks, long timeout)
          Performs several tasks synchronously with a given timeout in parallel threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Executor getInstance()
Returns the only instance of this class (singleton pattern).

Returns:
the only instance of this class

performAsynchronously

public <T> void performAsynchronously(java.util.concurrent.Callable<T> task,
                                      ExecutionFinishedListener<T> finishedListener)
Performs a task asynchronously (in an independent thread) without any time limit.

Type Parameters:
T - type of return value
Parameters:
task - task to be performed (specified in the Callable.call() method)
finishedListener - notified when the method call finishes (succesfully or abnormally), may be null

performAsynchronously

public <T> void performAsynchronously(java.util.concurrent.Callable<T> task,
                                      ExecutionFinishedListener<T> finishedListener,
                                      long timeout)
Performs a task asynchronously (in an independent thread) with a given time limit.

Type Parameters:
T - type of return value
Parameters:
task - task to be performed (specified in the Callable.call()} method)
finishedListener - notified when the method call finishes (succesfully or abnormally), may be null
timeout - maximum time allowed for execution in milliseconds

performSynchronously

public <T> T performSynchronously(java.util.concurrent.Callable<T> task,
                                  long timeout)
                       throws java.util.concurrent.CancellationException,
                              java.lang.InterruptedException,
                              java.lang.Throwable
Performs a task synchronously with a given timeout.

Type Parameters:
T - type of return value
Parameters:
task - tasks to be performed (specified in the Callable.call() method)
timeout - maximum time allowed for execution in milliseconds
Returns:
result value of the called method
Throws:
java.util.concurrent.CancellationException - if the execution time exceeds the specified timeout / thread has been cancelled
java.lang.InterruptedException - if interrupted while waiting, in which case unfinished tasks are cancelled
java.lang.Throwable - if the tasks throws an exception itself

performSynchronously

public <T> java.util.List<ExecutionFinishedEvent<T>> performSynchronously(java.util.List<java.util.concurrent.Callable<T>> tasks)
                                                               throws java.lang.InterruptedException
Performs several tasks synchronously in parallel threads.

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.

Type Parameters:
T - the result type of the callables
Parameters:
tasks - tasks to be performed (specified in the Callable.call() methods)
Returns:
ExecutionFinishedEvents for all tasks
Throws:
java.lang.InterruptedException - if the current thread was interrupted while waiting

performSynchronously

public <T> java.util.List<ExecutionFinishedEvent<T>> performSynchronously(java.util.List<java.util.concurrent.Callable<T>> tasks,
                                                                          long timeout)
                                                               throws java.lang.InterruptedException
Performs several tasks synchronously with a given timeout in parallel threads.

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.

Type Parameters:
T - the result type of the tasks
Parameters:
tasks - tasks to be performed (specified in the Callable.call() methods)
timeout - maximum time allowed for execution (in milliseconds)
Returns:
ExecutionFinishedEvents for all tasks
Throws:
java.lang.InterruptedException - if the current thread was interrupted while waiting

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org