public class ThreadPool extends ThreadGroup
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_THREADS |
static int |
DEFAULT_MIN_THREADS |
static long |
DEFAULT_THREAD_TIME |
Constructor and Description |
---|
ThreadPool()
Instanciate a new ThreadPool using defaults.
|
ThreadPool(int minThreads,
int maxThreads,
long timeUnused)
Instanciate a new ThreadPool with the specified minimum and
maximum number of active threads.
|
Modifier and Type | Method and Description |
---|---|
void |
runThis(Runnable item)
Run a runnable in a pool thread.
|
void |
runThis(Runnable item,
int pri)
Run a runnable in a pool thread.
|
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
public static int DEFAULT_MIN_THREADS
public static int DEFAULT_MAX_THREADS
public static long DEFAULT_THREAD_TIME
public ThreadPool()
public ThreadPool(int minThreads, int maxThreads, long timeUnused)
minThreads
- The minimum number of threads to keep in the pool
Defaults to 0. THese are started immediatly
(in another thread)maxThreads
- The maximum number of threads allowed. Tho pool
will be allowed to grow to this many threads,
if needed. Defaults to 20.timeUnused
- The amount of time (in ms) a thread is allowed to
remain unused before being terminated. If 0,
then threads will never die. Defaults to 0.public void runThis(Runnable item)
item
- A runnable item to run in the next threadpublic void runThis(Runnable item, int pri)
item
- A runnable item to run in the next threadCopyright © 2003, 2023, Oracle and/or its affiliates.