remm 2003/09/07 06:25:26 Modified: util/java/org/apache/tomcat/util/threads ThreadPool.java Log: - Null a busy processor in the pool array. This isn't particularly useful, but is more consistent with the rest of the algorithm, and helps get a clearer picture when debugging. Revision Changes Path 1.13 +13 -4 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java Index: ThreadPool.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ThreadPool.java 28 Jul 2003 11:23:56 -0000 1.12 +++ ThreadPool.java 7 Sep 2003 13:25:26 -0000 1.13 @@ -308,14 +308,16 @@ private ControlRunnable findControlRunnable() { ControlRunnable c=null; - if(0 == currentThreadCount || stopThePool) { + if (0 == currentThreadCount || stopThePool) { throw new IllegalStateException(); } + // Obtain a free thread from the pool. synchronized(this) { - if(currentThreadsBusy == currentThreadCount) { + + if (currentThreadsBusy == currentThreadCount) { // All threads are busy - if(currentThreadCount < maxThreads) { + if (currentThreadCount < maxThreads) { // Not all threads were open, // Open new threads up to the max number of idel threads int toOpen = currentThreadCount + minSpareThreads; @@ -345,8 +347,11 @@ } // If we are here it means that there is a free thread. Take it. - c = pool[currentThreadCount - currentThreadsBusy - 1]; + int pos = currentThreadCount - currentThreadsBusy - 1; + c = pool[pos]; + pool[pos] = null; currentThreadsBusy++; + } return c; } @@ -395,6 +400,7 @@ if(stopThePool) { return; } + if((currentThreadCount - currentThreadsBusy) > maxSpareThreads) { int toFree = currentThreadCount - currentThreadsBusy - @@ -406,7 +412,9 @@ pool[currentThreadCount - currentThreadsBusy - 1] = null; currentThreadCount --; } + } + } /** @@ -527,6 +535,7 @@ public void run() { while(true) { try { + // Sleep for a while. synchronized(this) { this.wait(WORK_WAIT_TIMEOUT);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]