public class ThreadPools
extends java.lang.Object
Constructor and Description |
---|
ThreadPools() |
Modifier and Type | Method and Description |
---|---|
static <T> com.google.common.util.concurrent.ListenableFuture<java.util.List<T>> |
runWithAvailableThreads(java.util.concurrent.ThreadPoolExecutor executor,
int poolSize,
java.util.Collection<java.util.concurrent.Callable<T>> callableCollection,
com.google.common.base.Function<java.util.List<T>,T> mergeFunction)
runs each runnable of the runnableCollection in it's own thread unless there aren't enough threads available.
|
public static <T> com.google.common.util.concurrent.ListenableFuture<java.util.List<T>> runWithAvailableThreads(java.util.concurrent.ThreadPoolExecutor executor, int poolSize, java.util.Collection<java.util.concurrent.Callable<T>> callableCollection, com.google.common.base.Function<java.util.List<T>,T> mergeFunction) throws java.util.concurrent.RejectedExecutionException
T
- type of the final resultexecutor
- executor that is used to execute the callableListpoolSize
- the corePoolSize of the given executorcallableCollection
- a collection of callable that should be executedmergeFunction
- function that will be applied to merge the results of multiple callable in case that they are
executed together if the threadPool is exhaustedjava.util.concurrent.RejectedExecutionException
- in case all threads are busy and overloaded.