thread.start();
totalThreadCreatedCount++; // 4682740
}
public void run() {
Servicable task = null;
try {
while (true) {
boolean canCreateBuddy = false;
do {
synchronized (poolProps) {
waitCount++;
}
task = null; // Bug 4700462 - Intermittent objects hang on to threads blocked on queue
task = (Servicable) taskQueue.remove(poolProps.maxIdleTime);
synchronized (poolProps) {
waitCount--;
if (task == null) {
// We timedout!!
if (poolProps.createdCount > poolProps.minThreadCount) {
//there are too many threads and the system is idle.
// if (bDebug) System.out.println(Thread.currentThread().getName()
// + " Timedout. (quitting)....");
//Bug 4677074 begin
// if (com.sun.enterprise.util.logging.Debug.enabled) _logger.log(Level.FINE,Thread.currentThread().getName()+ " Timedout. (quitting)....");
//Bug 4677074 end
// DIE!!!!
poolProps.createdCount--;
totalThreadDestroyedCount++; // 4682740
return;
}
// We get to live a little longer!
continue;
}
canCreateBuddy = (waitCount == 0) &&
(poolProps.createdCount < poolProps.maxThreadCount);
// Increment createdCount in anticipation of buddy creation
if (canCreateBuddy) poolProps.createdCount++;
numMessages++;
}
if (canCreateBuddy) {
// if (bDebug) System.out.println(Thread.currentThread().getName()
// + " creating buddy...");
//Bug 4677074 begin
// if (com.sun.enterprise.util.logging.Debug.enabled) _logger.log(Level.FINE,Thread.currentThread().getName()+ " creating buddy...");
//Bug 4677074 end
new ThreadPoolThread(poolProps);
}
// if (bDebug) System.out.println(Thread.currentThread().getName()
// + " got a task: " + task);
//Bug 4677074 begin
// if (com.sun.enterprise.util.logging.Debug.enabled) _logger.log(Level.FINE,Thread.currentThread().getName() + " got a task: " + task);
//Bug 4677074 end
try {
task.prolog();
task.service();
task.epilog();
} catch (Throwable th) {
//Bug 4677074 th.printStackTrace();
//Bug 4677074 begin
_logger.log(Level.SEVERE,"iplanet_util.generic_exception",th);
//Bug 4677074 end