Project Wonder 5.0

er.extensions.concurrency
Class ERXExecutorService

java.lang.Object
  extended by er.extensions.concurrency.ERXExecutorService

public class ERXExecutorService
extends java.lang.Object

A simple class that provides a resource-efficient WebObjects-friendly ExecutorService for a single application. ExecutorService instances are used for running tasks in asynchronous threads. Access the shared instance with:

 ExecutorService es = ERXExecutorService.executorService();
 

This class also provides a factory method to create a fixed size thread pool ExecutorService that rejects tasks when all threads are busy. This can be useful for parallel processing tasks.

Implements custom Thread and ThreadPoolExecutor subclasses that cooperate to maintain reference to currently executing task while executing and to ensure locked editing contexts are unlocked at the end of a task.

See Also:
ERXTaskThreadPoolExecutor, ERXTaskThreadFactory, ERXTaskThread, ERXExecutorService

Constructor Summary
ERXExecutorService()
           
 
Method Summary
static java.util.concurrent.ExecutorService executorService()
           
static java.util.concurrent.ExecutorService newFiniteThreadPool(int nThreads)
          This ExecutorService is useful when you want to execute tasks in parallel, but you want to (create and) submit new tasks for execution only when the pool has at least one idle thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXExecutorService

public ERXExecutorService()
Method Detail

executorService

public static java.util.concurrent.ExecutorService executorService()
Returns:
a global ExecutorService with no limit for executing runnables.

newFiniteThreadPool

public static java.util.concurrent.ExecutorService newFiniteThreadPool(int nThreads)
This ExecutorService is useful when you want to execute tasks in parallel, but you want to (create and) submit new tasks for execution only when the pool has at least one idle thread. A task will be rejected with a RejectedExecutionException when all the threads are busy running other tasks. Thus, you can fill the pool with tasks and use a try/catch/wait loop for submitting additional tasks. Idle threads will be terminated if idle for more than 30 seconds.

Parameters:
nThreads -
Returns:
a fixed-size thread pool that only accepts tasks when a thread is idle.

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.