public final class Scheduler extends java.lang.Object implements Pool
Self regulation happened according to following rules:
| Modifier and Type | Class and Description |
|---|---|
private class |
Scheduler.WatchdogThread |
private class |
Scheduler.WorkerThread |
| Modifier and Type | Field and Description |
|---|---|
private long |
lastTaskPoke |
private static long |
POKE_INTERVAL |
private java.util.concurrent.BlockingQueue<java.lang.Runnable> |
queue |
private long |
schedulerTime |
(package private) static java.lang.RuntimeException |
TERMINATE |
private boolean |
terminating |
private java.util.concurrent.atomic.AtomicInteger |
threadCount |
POOL_SIZE_MUST_BE_A_POSITIVE_NUMBER, UNCAUGHT_EXCEPTION_OCCURRED_IN_GPARS_POOL| Modifier and Type | Method and Description |
|---|---|
void |
execute(java.lang.Runnable task)
schedules a new task for processing with the pool
|
int |
getPoolSize()
Retrieves the current thread pool size
|
java.lang.Runnable |
loop(java.lang.Runnable operation) |
void |
resetDefaultSize()
Sets the pool size to the default
|
void |
resize(int poolSize)
Resizes the thread pool to the specified value
|
void |
shutdown()
Gently stops the pool
|
private void |
startNewThread() |
private final java.util.concurrent.BlockingQueue<java.lang.Runnable> queue
private final java.util.concurrent.atomic.AtomicInteger threadCount
private volatile long lastTaskPoke
private volatile long schedulerTime
private volatile boolean terminating
static final java.lang.RuntimeException TERMINATE
private static final long POKE_INTERVAL
public void execute(java.lang.Runnable task)
Poolpublic java.lang.Runnable loop(java.lang.Runnable operation)
private void startNewThread()
public void resize(int poolSize)
Poolpublic void resetDefaultSize()
PoolresetDefaultSize in interface Poolpublic int getPoolSize()
getPoolSize in interface Pool