Package edu.jas.kern
Class ComputerThreads
- java.lang.Object
-
- edu.jas.kern.ComputerThreads
-
public class ComputerThreads extends java.lang.Object
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 withComputerThreads.terminate()to exit JAS.- Author:
- Heinz Kredel
-
-
Field Summary
Fields Modifier and Type Field Description static intN_CPUSNumber of processors.static intN_THREADSstatic booleanNO_THREADSFlag for thread usage.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ExecutorServicegetPool()Get the thread pool.static longgetTimeout()Get timeout.static java.util.concurrent.TimeUnitgetTimeUnit()Get TimeUnit.static booleanisRunning()Test if a pool is running.static voidsetNoThreads()Set no thread usage.static voidsetThreads()Set thread usage.static voidsetTimeout(long t)Set timeout.static voidsetTimeUnit(java.util.concurrent.TimeUnit t)Set TimeUnit.static voidterminate()Stop execution.
-
-
-
Field Detail
-
NO_THREADS
public static boolean NO_THREADS
Flag for thread usage. Note: Only introduced because Google app engine does not support threads.
-
N_CPUS
public static final int N_CPUS
Number of processors.
-
N_THREADS
public static final int N_THREADS
-
-
Method Detail
-
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
public static java.util.concurrent.ExecutorService 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
public static void setTimeUnit(java.util.concurrent.TimeUnit t)
Set TimeUnit.- Parameters:
t- TimeUnit value to set
-
getTimeUnit
public static java.util.concurrent.TimeUnit getTimeUnit()
Get TimeUnit.- Returns:
- timeunit value
-
-