public interface IThreadPool
executeAs(Runnable, boolean)
executions on the same pool
will share one work unit, while switching from one
pool to another will lead to independent work units.
Threads not owned by this pool may be joined into this pool (and hence the workunit mechanism and the max concurrency config) via the executeAs method.Modifier and Type | Method | Description |
---|---|---|
void |
execute(boolean block,
java.lang.Runnable... runnables) |
short hand method.
|
void |
execute(boolean block,
java.util.Collection<? extends java.lang.Runnable> runnables) |
Execute the passed on tasks concurrently within the bounds of the pools configured
maximal concurrency.
|
void |
executeAs(java.lang.Runnable runnable,
boolean maxconcurrency) |
Incorporate the current thread logically into the pool, if it is not one of the pool's threads and execute the runnable.
|
<T> T |
executeAs(java.util.concurrent.Callable<T> runnable,
boolean maxconcurrency) |
Like above, but excepting a callable and thereby providing for an exception flow and a return value
|
int |
getMaxAchievedConcurrency() |
get the max achieved concurrency
|
int |
getMaxConcurrency() |
sets the max concurrency for this thread pool.
|
boolean |
isPoolThread(java.lang.Thread t) |
checks whether a given thread is of this pool
|
void |
setMaxConcurrency(int maxconcurrency) |
sets the max concurrency for this thread pool.
|
void execute(boolean block, java.util.Collection<? extends java.lang.Runnable> runnables)
In case a non-blocking execution is required, all tasks will be put into the threadpool's task queue. In extreme cases this may imply
that no task will be started before the current thread returns to the pool.
In particular, if the calling thread is from the same pool, it is crucial to not have the calling thread wait
for the completion of the tasks, as those may never get started as all the pool's threads are busy. If a number of tasks need to be
completed and the current thread must not return to the pool before completion, this method should be called indicating a blocking
execution
runnables
- an array of runnables to be executed.block
- if true
the current thread will not return until all runnables have executed. If false
, the
current thread will return immediately.WorkException
- if there occurred an uncaught and non-severe exception during
execution of a runnable. Any runnables that has not been started yet will not be started at all.void execute(boolean block, java.lang.Runnable... runnables)
runnables
- block
- if true
the current thread will not return until all runnables have executed. If false
, the
current thread will not return if it is from the same thread pool and will return otherwise.void setMaxConcurrency(int maxconcurrency)
int getMaxConcurrency()
int getMaxAchievedConcurrency()
boolean isPoolThread(java.lang.Thread t)
void executeAs(java.lang.Runnable runnable, boolean maxconcurrency)
<T> T executeAs(java.util.concurrent.Callable<T> runnable, boolean maxconcurrency) throws java.lang.Exception
java.lang.Exception