Acme
Class Utils.ThreadPool
java.lang.Object
Acme.Utils.ThreadPool
- Enclosing class:
- Utils
public static final class Utils.ThreadPool
- extends Object
MAXNOTHREAD
public static final String MAXNOTHREAD
- See Also:
- Constant Field Values
counter
protected static int counter
freeThreads
protected ArrayList freeThreads
busyThreads
protected HashMap busyThreads
maxThreads
protected int maxThreads
threadFactory
protected Utils.ThreadFactory threadFactory
Utils.ThreadPool
public 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
- 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(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 Throwable
- Overrides:
finalize
in class Object
- Throws:
Throwable
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2011. All Rights Reserved.