public class NonstopThreadPool
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
NonstopThreadPool.ReaperThread
class which manages the alive non stop threads
|
private static class |
NonstopThreadPool.State
Private enum maintaining state of the pool
|
private static class |
NonstopThreadPool.WeakWorkerReference
private class maintaining the app thread and its corresponding worker thread
|
private static class |
NonstopThreadPool.Worker
Worker class
|
private static class |
NonstopThreadPool.WorkerTaskHolder
Private class maintaining single pending task
|
private static class |
NonstopThreadPool.WorkerThreadLocal
Private class
|
Modifier and Type | Field and Description |
---|---|
private java.lang.ref.ReferenceQueue<java.lang.Thread> |
gcedThreadsReferenceQueue |
private static long |
NUM_OF_POLLS_BEFORE_CHECK_THREADS_ALIVE |
private static long |
POLL_TIME_MILLIS |
private java.util.concurrent.atomic.AtomicReference<NonstopThreadPool.State> |
state |
private java.util.concurrent.ThreadFactory |
threadFactory |
private java.util.Map<java.lang.Thread,NonstopThreadPool.WorkerThreadLocal> |
workers |
private java.lang.Object |
workersLock |
private VicariousThreadLocal<NonstopThreadPool.WorkerThreadLocal> |
workerThreadLocal |
Constructor and Description |
---|
NonstopThreadPool(java.util.concurrent.ThreadFactory threadFactory)
Constructor accepting the threadFactory
|
Modifier and Type | Method and Description |
---|---|
java.lang.StackTraceElement[] |
getNonstopThreadStackTrace()
Get the stack trace details of the nonstop thread for the current thread
|
private void |
rejectExecutionAfterShutdown() |
void |
shutdownNow()
Shuts down the thread pool
|
private void |
startReaperThread() |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task)
Submit a callable task to be executed by the thread pool
|
private static final long POLL_TIME_MILLIS
private static final long NUM_OF_POLLS_BEFORE_CHECK_THREADS_ALIVE
private final java.util.concurrent.ThreadFactory threadFactory
private final java.util.Map<java.lang.Thread,NonstopThreadPool.WorkerThreadLocal> workers
private final java.lang.Object workersLock
private final java.util.concurrent.atomic.AtomicReference<NonstopThreadPool.State> state
private final java.lang.ref.ReferenceQueue<java.lang.Thread> gcedThreadsReferenceQueue
private final VicariousThreadLocal<NonstopThreadPool.WorkerThreadLocal> workerThreadLocal
public NonstopThreadPool(java.util.concurrent.ThreadFactory threadFactory)
threadFactory
- private void startReaperThread()
private void rejectExecutionAfterShutdown()
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
T
- task
- public void shutdownNow()
public java.lang.StackTraceElement[] getNonstopThreadStackTrace()