public final class SimpleThreadPool extends Object implements Runnable, ThreadPool
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NUM_THREAD
Default number of threads in the thread pool.
|
static int |
MAX_WAIT_FOR_STOP
Maximum amount of time to wait for a thread to stop.
|
static int |
MAX_WAIT_FOR_TASK
Maximum amount of time to wait for a task from the queue in milli seconds.
|
| Constructor and Description |
|---|
SimpleThreadPool()
Constructor.
|
SimpleThreadPool(DNotesMonitor monitor)
Constructor.
|
SimpleThreadPool(DNotesMonitor monitor,
int numberOfThreads)
Constructor.
|
SimpleThreadPool(DNotesMonitor monitor,
int numberOfThreads,
int threadPriority)
Constructor.
|
SimpleThreadPool(DNotesMonitor monitor,
ThreadFactory threadFactory,
int numberOfThreads)
Constructor.
|
SimpleThreadPool(DNotesMonitor theMonitor,
ThreadFactory theThreadFactory,
int theNumberOfThreads,
int theThreadPriority)
Constructor.
|
SimpleThreadPool(int numberOfThreads)
Constructor.
|
SimpleThreadPool(int numberOfThreads,
int threadPriority)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getRunnableCount()
Returns number of runnable objects in the queue.
|
void |
invokeLater(Runnable task)
Dispatch a new task onto this pool to be invoked asynchronously later.
|
void |
resize(int newSize)
Resize the thread pool.
|
void |
run()
The method ran by the pool of background threads.
|
void |
stop()
Stops the pool.
|
public static final int MAX_WAIT_FOR_TASK
public static final int MAX_WAIT_FOR_STOP
public static final int DEFAULT_NUM_THREAD
public SimpleThreadPool()
throws ThreadPoolException
ThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(DNotesMonitor monitor) throws ThreadPoolException
monitor - the monitorThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(int numberOfThreads)
throws ThreadPoolException
numberOfThreads - number of threads in poolThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(DNotesMonitor monitor, int numberOfThreads) throws ThreadPoolException
monitor - ThreadPool MonitornumberOfThreads - number of threads in poolThreadPoolException - if any error occurs during starting threadsThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(int numberOfThreads,
int threadPriority)
throws ThreadPoolException
numberOfThreads - number of threads in poolthreadPriority - priority of threads in poolThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(DNotesMonitor monitor, int numberOfThreads, int threadPriority) throws ThreadPoolException
monitor - ThreadPool MonitornumberOfThreads - number of threads in poolthreadPriority - priority of threads in poolThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(DNotesMonitor monitor, ThreadFactory threadFactory, int numberOfThreads) throws ThreadPoolException
monitor - ThreadPool MonitorthreadFactory - ThreadFactory to us to create the new ThreadsnumberOfThreads - number of threads in poolThreadPoolException - if any error occurs during starting threadspublic SimpleThreadPool(DNotesMonitor theMonitor, ThreadFactory theThreadFactory, int theNumberOfThreads, int theThreadPriority) throws ThreadPoolException
theMonitor - ThreadPool monitortheThreadFactory - ThreadFactory to us to create the new ThreadstheNumberOfThreads - number of threads in pooltheThreadPriority - priority of threads in poolThreadPoolException - if any error occurs during starting threadspublic int getRunnableCount()
public void invokeLater(Runnable task)
invokeLater in interface ThreadPooltask - the task to executepublic void stop()
ThreadPoolstop in interface ThreadPoolThreadPool.stop()public void resize(int newSize)
throws ThreadPoolException
resize in interface ThreadPoolnewSize - new number of threads in the thread poolThreadPoolException - if any error occurs during starting threadsThreadPool.resize(int)Copyright © 2005–2020. All rights reserved.