Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: restore

Scrollbar

The ParallelExecutor service allows a computation to occur in parallel.

It can be used in two ways. First, with an explicit Future:

Code Block
java
java
   Future<String> future = executor.invoke(new Invokable<String>() { ... });

The executor will submit the Invokable to a thread pool for execution in the background.

...

Another alternative will return an object proxy, not a Future:

Code Block
java
java
  RSSFeed feed = executor.invoke(RSSFeed.class, new Invokable<RSSFeed>() { ... });

This only works if the type is an interface. A proxy for the interface is created around the Future object; any invocation on the proxy will invoke get() on the Future (that is, will block until the value is computed).

...

Since
since5.3
 
The size of the task queue. When there are at least the core number of threads in the pool, tasks will be placed in the queue. If the queue is empty, more threads may be created (up to the maximum pool size). If the queue is full and all threads have been created, the task is rejected (and exception is thrown).

Defaults to 100.

 

Scrollbar