FastThreadPoolpublic class FastThreadPool extends Object This implementation runs a thread and does the following:
a) Picks a task from the task queue
b) Removes one thread from the (thread)Pool.
c) notifies the threadPoolThread. |
Fields Summary |
---|
static Logger | _logger | protected boolean | bDebug | private PoolProperties | poolProps | private TaskQueue | taskQueue | private int | waitCount | private int | totalThreadCreatedCount | private int | totalThreadDestroyedCount | private int | numMessages |
Constructors Summary |
---|
public FastThreadPool(String threadGroupName, int minThreadCount, int maxThreadCount, long maxIdleTime, int queueLimit, TaskFactory factory)
this(new ThreadGroup(threadGroupName), minThreadCount, maxThreadCount,
maxIdleTime, new TaskQueue(queueLimit, factory));
| public FastThreadPool(ThreadGroup threadGroup, int minThreadCount, int maxThreadCount, long maxIdleTime, int queueLimit, TaskFactory factory)
this(threadGroup, minThreadCount, maxThreadCount, maxIdleTime,
new TaskQueue(queueLimit, factory));
| public FastThreadPool(ThreadGroup threadGroup, int minThreadCount, int maxThreadCount, long maxIdleTime, TaskQueue queue)
this.taskQueue = queue;
poolProps = new PoolProperties(minThreadCount, maxThreadCount,
maxIdleTime, taskQueue, threadGroup);
|
Methods Summary |
---|
public void | abort()
taskQueue.abort();
| public void | add(int index, com.sun.enterprise.util.threadpool.Servicable servicable)Add the job at the specified position. Probably based on priority?
taskQueue.add(index, servicable);
| public void | addFirst(com.sun.enterprise.util.threadpool.Servicable servicable)Add to the head of the queue. Probably a high priority job?
taskQueue.addFirst(servicable);
| public void | addLast(com.sun.enterprise.util.threadpool.Servicable servicable)Add to the tail of the queue.
taskQueue.addLast(servicable);
| public int[] | getMonitoredValues()
synchronized(poolProps) {
// Return the two integer values as an array.
int [] ret = {(poolProps != null) ? (poolProps.createdCount) : -1,
waitCount};
return ret;
}
| public int | getPoolSize()
return (poolProps != null) ? (poolProps.createdCount) : -1;
| public TaskQueue | getTaskQueue()returns the task queue
return taskQueue;
| public int | getWaitCount()
return waitCount;
| public boolean | setTaskQueue(TaskQueue bq)sets the task queue. Returns true if successful
if (taskQueue != null)
return false;
taskQueue = bq;
return true;
| public void | shutdown()
taskQueue.shutdown();
| public void | start()Start the threadpool. Needed for scenarios where the queue gets
created and set in the threadpool from some other object.
// We set createdCount to be the number of threads we are creating
poolProps.createdCount = poolProps.minThreadCount;
for (int i=0; i < poolProps.minThreadCount; i++) {
// if (bDebug) System.out.println("FastThreadPool creating thread: "
// + i + "/" + poolProps.minThreadCount);
//Bug 4677074 begin
// if (com.sun.enterprise.util.logging.Debug.enabled) _logger.log(Level.FINE,"FastThreadPool creating thread: "+ i + "/" + poolProps.minThreadCount);
//Bug 4677074 end
new ThreadPoolThread(poolProps);
}
// START OF IASRI 4682740
com.sun.enterprise.util.MonitorTask.addORBMonitorable(this);
// END OF IASRI 4682740
| public java.lang.String | toString()Great for monitoring. All methods used here are unsynchronized.
StringBuffer sb = new StringBuffer();
sb.append("FastThreadPool [CS=").append(poolProps.createdCount);
sb.append(", TC=").append(totalThreadCreatedCount);
sb.append(", TD=").append(totalThreadDestroyedCount);
sb.append(", Min=").append(poolProps.minThreadCount);
sb.append(", Max=").append(poolProps.maxThreadCount);
sb.append(", MaxIdle=").append(poolProps.maxIdleTime);
sb.append(", Msgs=").append(numMessages);
sb.append("]");
return sb.toString();
|
|