Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.deegree.framework.concurrent
Class Executor

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

    public class Executor

extends Object

The `Executor` is deegree's central place to:

- Perform a task asynchronously (in an independent thread) optionally with a maximum execution time.
- Perform a task synchronously with a maximum execution time.
- Perform several task synchronously (but in parallel threads) with a maximum execution time.

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(Callable<T> task, ExecutionFinishedListener<T> finishedListener)` Performs a task asynchronously (in an independent thread) without any time limit.
`
`<T> void`
` | `performAsynchronously(Callable<T> task, ExecutionFinishedListener<T> finishedListener, long timeout)` Performs a task asynchronously (in an independent thread) with a given time limit.
`
`<T> T`
` | `performSynchronously(Callable<T> task, long timeout)` Performs a task synchronously with a given timeout.
`
`<T> List<ExecutionFinishedEvent<T>>`
` | `performSynchronously(List<Callable<T>> tasks)` Performs several tasks synchronously in parallel threads.
`
`<T> List<ExecutionFinishedEvent<T>>`
` | `performSynchronously(List<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(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(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(Callable<T> task,
                                      long timeout)
                           throws CancellationException,
                                  InterruptedException,
                                  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:
    `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 itself

### performSynchronously

    public <T> List<ExecutionFinishedEvent<T>> performSynchronously(List<Callable<T>> tasks)
                                                         throws 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:
    `InterruptedException` - if the current thread was interrupted while waiting

### performSynchronously

    public <T> List<ExecutionFinishedEvent<T>> performSynchronously(List<Callable<T>> tasks,
                                                                    long timeout)
                                                         throws 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:
    `InterruptedException` - if the current thread was interrupted while waiting

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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