Package edu.jas.kern
Class ComputerThreads
java.lang.Object
edu.jas.kern.ComputerThreads
ComputerThreads, provides global thread / executor service.
Usage: To obtain a reference to the thread pool use
ComputerThreads.getPool()
. Once a pool has been created it must
be shutdown with ComputerThreads.terminate()
to exit JAS.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.logging.log4j.Logger
static final int
Number of processors.static final int
static boolean
Flag for thread usage.(package private) static ExecutorService
ExecutorService thread pool.(package private) static long
Timeout for timed execution.(package private) static TimeUnit
TimeUnit for timed execution. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutorService
getPool()
Get the thread pool.static long
Get timeout.static TimeUnit
Get TimeUnit.static boolean
Test if a pool is running.static void
Set no thread usage.static void
Set thread usage.static void
setTimeout
(long t) Set timeout.static void
Set TimeUnit.static void
Stop execution.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
NO_THREADS
public static boolean NO_THREADSFlag for thread usage. Note: Only introduced because Google app engine does not support threads.- See Also:
-
N_CPUS
public static final int N_CPUSNumber of processors. -
N_THREADS
public static final int N_THREADS -
timeout
static long timeoutTimeout for timed execution.- See Also:
-
timeunit
TimeUnit for timed execution.- See Also:
-
pool
ExecutorService thread pool.
-
-
Constructor Details
-
ComputerThreads
private ComputerThreads()No public constructor.
-
-
Method Details
-
isRunning
public static boolean isRunning()Test if a pool is running.- Returns:
- true if a thread pool has been started or is running, else false.
-
getPool
Get the thread pool.- Returns:
- pool ExecutorService.
-
terminate
public static void terminate()Stop execution. -
setNoThreads
public static void setNoThreads()Set no thread usage. -
setThreads
public static void setThreads()Set thread usage. -
setTimeout
public static void setTimeout(long t) Set timeout.- Parameters:
t
- time value to set
-
getTimeout
public static long getTimeout()Get timeout.- Returns:
- timeout value
-
setTimeUnit
Set TimeUnit.- Parameters:
t
- TimeUnit value to set
-
getTimeUnit
Get TimeUnit.- Returns:
- timeunit value
-