public class LogicalThreadPool extends Object implements Serializable
Can be used to control a logical pool of threads per user session.
| Constructor and Description |
|---|
LogicalThreadPool()
Default constructor with default name and no limit to threads.
|
LogicalThreadPool(String name,
int max) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkPoolStatus()
Check if the pool is OK for processing.
|
void |
finished()
Called when a thread finishes processing.
|
boolean |
getAccess() |
boolean |
getAccess(long timeout,
TimeUnit unit) |
int |
getCurrent() |
int |
getMax() |
String |
getName() |
boolean |
isShutdown() |
protected void |
setShutdown(boolean shutdown) |
void |
shutdownPool()
Shutdown the thread pool.
|
void |
startPool()
Start the thread pool.
|
void |
waitAccess()
Wait till a thread is available.
|
void |
waitAccess(int waitInterval,
int maxWaitIntervals)
Wait till a thread is available.
|
public LogicalThreadPool()
public LogicalThreadPool(String name, int max)
name - thread pool namemax - the maximum threads. Zero means no limit.public final String getName()
public final int getMax()
public int getCurrent()
public boolean isShutdown()
public void shutdownPool()
public void startPool()
public void finished()
public boolean getAccess()
public boolean getAccess(long timeout,
TimeUnit unit)
timeout - the wait intervalunit - the interval unitpublic void waitAccess()
Must call finished on pool to release the thread in the pool.
public void waitAccess(int waitInterval,
int maxWaitIntervals)
Must call finished on pool to release the thread in the pool.
waitInterval - the wait interval in millisecondsmaxWaitIntervals - the max number of waitsprotected void checkPoolStatus()
protected void setShutdown(boolean shutdown)
shutdown - true if pool shutdown for processingCopyright © 2019. All rights reserved.