Modifier and Type | Field and Description |
---|---|
protected HashMap |
busyThreads |
protected static int |
counter |
protected ArrayList |
freeThreads |
static String |
MAXNOTHREAD |
protected int |
maxThreads |
protected Utils.ThreadFactory |
threadFactory |
Constructor and Description |
---|
Utils.ThreadPool(Properties properties,
Utils.ThreadFactory threadfactory)
Creates a thread pool not queued with max number of threads defined in properties or DEF_MAX_POOLED_THREAD = 20
|
Modifier and Type | Method and Description |
---|---|
void |
executeThread(Runnable runnable)
Takes a new task for execution by a threads in pool will wait until free threads if number of threads reached max
|
protected void |
finalize() |
int |
getMaxThreads()
Returns setting for max number of threads
|
void |
setMaxThreads(int newSize)
Assigns a new value for max threads
|
String |
toString() |
public static final String MAXNOTHREAD
protected static int counter
protected ArrayList freeThreads
protected HashMap busyThreads
protected int maxThreads
protected Utils.ThreadFactory threadFactory
public Utils.ThreadPool(Properties properties, Utils.ThreadFactory threadfactory)
Properties
- where property THREADSINPOOL gives max threads Note if THREADSINPOOL not integers, or negative then DEF_MAX_POOLED_THREAD usedpublic void setMaxThreads(int newSize)
int
- new value of max threads, can't be less than 2, but can be 0 If current number threads exceed the value, then extra thread will be
discarded gracefullypublic int getMaxThreads()
public void executeThread(Runnable runnable)
Runnable
- task for executionprotected void finalize() throws Throwable
Copyright © 2014. All Rights Reserved.