remm 2004/01/08 05:56:36 Modified: util/java/org/apache/tomcat/util/threads ThreadPool.java Log: - Some suggestions that were sent by Dave Dice. Jean François assured me he did test this, so since this looks harmless to me (and won't hurt performance either), I'm willing to try them. Actually, this looks to me that it won't do anything, but what do I know ;-) Revision Changes Path 1.20 +15 -9 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ThreadPool.java 25 Dec 2003 03:08:31 -0000 1.19 +++ ThreadPool.java 8 Jan 2004 13:56:36 -0000 1.20 @@ -644,17 +644,23 @@ } public void run() { + boolean _shouldRun = false; + boolean _shouldTerminate = false; + ThreadPoolRunnable _toRun = null; try { while(true) { try { /* Wait for work. */ synchronized(this) { - if(!shouldRun && !shouldTerminate) { + while (!shouldRun && !shouldTerminate) { this.wait(); } + _shouldRun = shouldRun; + _shouldTerminate = shouldTerminate; + _toRun = toRun; } - if( shouldTerminate ) { + if( _shouldTerminate ) { if( p.log.isDebugEnabled()) p.log.debug( "Terminate"); break; @@ -663,8 +669,8 @@ /* Check if should execute a runnable. */ try { if(noThData) { - if( toRun != null ) { - Object thData[]=toRun.getInitData(); + if( _toRun != null ) { + Object thData[]=_toRun.getInitData(); t.setThreadData(p, thData); if(p.log.isDebugEnabled()) p.log.debug( "Getting new thread data"); @@ -672,9 +678,9 @@ noThData = false; } - if(shouldRun) { - if( toRun != null ) { - toRun.runIt(t.getThreadData(p)); + if(_shouldRun) { + if( _toRun != null ) { + _toRun.runIt(t.getThreadData(p)); } else if( toRunRunnable != null ) { toRunRunnable.run(); } else { @@ -696,7 +702,7 @@ shouldRun = false; p.notifyThreadEnd(this); } finally { - if(shouldRun) { + if(_shouldRun) { shouldRun = false; /* * Notify the pool that the thread is now idle. @@ -709,7 +715,7 @@ * Check if should terminate. * termination happens when the pool is shutting down. */ - if(shouldTerminate) { + if(_shouldTerminate) { break; } } catch(InterruptedException ie) { /* for the wait operation */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]