public class GlobalPooledExecutor extends Object
The general idea is that a thread limit adapted to a specific use case
is introduced on top, so the thread pool is not used directly but by using a
LimitedPooledExecutor which provides an
ExecutorService interface.
After some time waiting a pool thread will die. If there is no work to be done no thread will be kept alive. Instead of defining a low pool size to have some threads always available for the typical workloads, each thread waits for a randomized idle time up to 30 minutes until it dies. This way the amount of threads staying in the pool adapts to the workload itself (hopefully...).
LimitedPooledExecutor,
ExecutorService| Modifier and Type | Class and Description |
|---|---|
static interface |
GlobalPooledExecutor.ProgressNotifier |
static class |
GlobalPooledExecutor.Tunable |
| Constructor and Description |
|---|
GlobalPooledExecutor(String _name) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Remove pending jobs from the task queue and stop threads in the pool.
|
<V> Future<V> |
execute(Callable<V> c) |
<V> Future<V> |
execute(Callable<V> c,
GlobalPooledExecutor.ProgressNotifier n) |
<V> Future<V> |
execute(Callable<V> c,
GlobalPooledExecutor.ProgressNotifier n,
long _timeoutMillis) |
void |
execute(Runnable r) |
void |
execute(Runnable r,
GlobalPooledExecutor.ProgressNotifier n) |
int |
getDiedThreadCount() |
int |
getPeakThreadCount() |
int |
getThreadInUseCount() |
int |
getTotalStartedThreadCount() |
void |
waitUntilAllDied() |
boolean |
wasWarningLimitReached()
Used for alerting.
|
public GlobalPooledExecutor(String _name)
_name - used for the thread name prefix.public void execute(Runnable r) throws InterruptedException, TimeoutException
InterruptedExceptionTimeoutExceptionpublic <V> Future<V> execute(Callable<V> c) throws InterruptedException, TimeoutException
InterruptedExceptionTimeoutExceptionpublic void execute(Runnable r, GlobalPooledExecutor.ProgressNotifier n) throws InterruptedException, TimeoutException
InterruptedExceptionTimeoutExceptionpublic <V> Future<V> execute(Callable<V> c, GlobalPooledExecutor.ProgressNotifier n) throws InterruptedException, TimeoutException
InterruptedExceptionTimeoutExceptionpublic <V> Future<V> execute(Callable<V> c, GlobalPooledExecutor.ProgressNotifier n, long _timeoutMillis) throws InterruptedException, TimeoutException
_timeoutMillis - 0 means immediately timeout, if no space is availableInterruptedExceptionTimeoutExceptionpublic void waitUntilAllDied()
public void close()
public int getTotalStartedThreadCount()
public int getThreadInUseCount()
public int getDiedThreadCount()
public boolean wasWarningLimitReached()
public int getPeakThreadCount()
cache2k API documentation. Copyright © 2000–2015 headissue GmbH, Munich.