|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.biojava3.core.util.ConcurrencyTools
public class ConcurrencyTools
Static utility to easily share a thread pool for concurrent/parallel/lazy execution. To exit cleanly,
shutdown() or shutdownAndAwaitTermination() must be called after all tasks have been submitted.
| Method Summary | ||
|---|---|---|
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
|
submit(Callable<T> task)
Queues up a task and adds a default log entry. |
|
static
|
submit(Callable<T> task,
String message)
Queues up a task and adds a log entry. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
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 message
public static <T> Future<T> submit(Callable<T> task)
T - type returned from the submitted tasktask - submitted task
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||