On Thu, Jul 26, 2001 at 03:07:55PM -0700, Renato Weiner wrote:
>
> I was running some volume tests with Tomcat 3.2.3 using the 'ab'
> application that comes with apache. I simulated diffent loads of
> concurrent users. If set the concurrency to 5 it runs fine my
> Servlets, but if I set to more than 8, I got an exception in the
> ThreadPool. Here is the message:
>
> 2001-07-26 19:00:14 - ThreadPool: Caught exception executing org.apache.tomcat.s
> ervice.TcpWorkerThread@799ff5, terminating thread - java.util.NoSuchElementExcep
> tion
> at java.util.Vector.lastElement(Vector.java:454)
> at org.apache.tomcat.util.ThreadPool.runIt(ThreadPool.java:234)
> at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
> 405)
> at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
> :501)
> at java.lang.Thread.run(Thread.java:484)
>
> The error is reproducable. If anybody send a patch I can test it.
I found the problem, below is the simplest patch to fix it, although not
100% correct. I'll explain why in a few minutes.
-Dave
--- ThreadPool.java.orig Sun Apr 22 19:16:03 2001
+++ ThreadPool.java Thu Jul 26 16:35:47 2001
@@ -197,7 +197,7 @@
// Obtain a free thread from the pool.
synchronized(this) {
- if(currentThreadsBusy == currentThreadCount) {
+ if(currentThreadsBusy >= currentThreadCount) {
// All threads are busy
if(currentThreadCount < maxThreads) {
// Not all threads were open,