public class ERXExecutorService extends 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.
Constructor and Description |
---|
ERXExecutorService() |
Modifier and Type | Method and Description |
---|---|
static ExecutorService |
executorService() |
static 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.
|
public static ExecutorService executorService()
public static ExecutorService newFiniteThreadPool(int nThreads)
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.nThreads
- Copyright © 2002 – 2020 Project Wonder.