public class ConcurrencyTools extends Object
shutdown()
or shutdownAndAwaitTermination()
must be called after all tasks have been submitted.Modifier and Type | Method and Description |
---|---|
static ThreadPoolExecutor |
getThreadPool()
Returns current shared thread pool.
|
static void |
setThreadPool(ThreadPoolExecutor pool)
Sets thread pool to any given
ThreadPoolExecutor to allow use of an alternative execution style. |
static void |
setThreadPoolCPUsAvailable(int cpus)
Sets thread pool to reserve a given number of processor cores for foreground or other use.
|
static void |
setThreadPoolCPUsFraction(float fraction)
Sets thread pool to a given fraction of the available processors.
|
static void |
setThreadPoolDefault()
Sets thread pool to default of 1 background thread for each processor core.
|
static void |
setThreadPoolSingle()
Sets thread pool to a single background thread.
|
static void |
setThreadPoolSize(int threads)
Sets thread pool to given size.
|
static void |
shutdown()
Disables new tasks from being submitted and closes the thread pool cleanly.
|
static void |
shutdownAndAwaitTermination()
Closes the thread pool.
|
static <T> Future<T> |
submit(Callable<T> task)
Queues up a task and adds a default log entry.
|
static <T> Future<T> |
submit(Callable<T> task,
String message)
Queues up a task and adds a log entry.
|
public static ThreadPoolExecutor getThreadPool()
public static void setThreadPoolCPUsAvailable(int cpus)
cpus
- number of processor cores to reservepublic static void setThreadPoolCPUsFraction(float fraction)
fraction
- portion of available processors to use in thread poolpublic static void setThreadPoolDefault()
public static void setThreadPoolSingle()
public static void setThreadPoolSize(int threads)
threads
- number of threads in poolpublic static void setThreadPool(ThreadPoolExecutor pool)
ThreadPoolExecutor
to allow use of an alternative execution style.pool
- thread pool to sharepublic static void shutdown()
public static void shutdownAndAwaitTermination()
public static <T> Future<T> submit(Callable<T> task, String message)
T
- type returned from the submitted tasktask
- submitted taskmessage
- logged messageCopyright © 2000–2018 BioJava. All rights reserved.