Acme
Class Utils.ThreadPool
java.lang.Object
Acme.Utils.ThreadPool
- Enclosing class:
- Utils
public static final class Utils.ThreadPool
- extends java.lang.Object
Constructor Summary |
Utils.ThreadPool(java.util.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 |
Method Summary |
void |
executeThread(java.lang.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 |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
MAXNOTHREAD
public static final java.lang.String MAXNOTHREAD
- See Also:
- Constant Field Values
counter
protected static int counter
freeThreads
protected java.util.ArrayList freeThreads
busyThreads
protected java.util.HashMap busyThreads
maxThreads
protected int maxThreads
threadFactory
protected Utils.ThreadFactory threadFactory
Utils.ThreadPool
public Utils.ThreadPool(java.util.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
- Parameters:
Properties
- where property THREADSINPOOL gives max threads Note if THREADSINPOOL not integers, or negative then DEF_MAX_POOLED_THREAD used
setMaxThreads
public void setMaxThreads(int newSize)
- Assigns a new value for max threads
- Parameters:
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 gracefully
getMaxThreads
public int getMaxThreads()
- Returns setting for max number of threads
- Returns:
- int setting for max number of threads, doesn't reflect actual number of threads though
executeThread
public void executeThread(java.lang.Runnable runnable)
- Takes a new task for execution by a threads in pool will wait until free threads if number of threads reached max
- Parameters:
Runnable
- task for execution
finalize
protected void finalize()
throws java.lang.Throwable
- Overrides:
finalize
in class java.lang.Object
- Throws:
java.lang.Throwable
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright © 2010. All Rights Reserved.