You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/10/16 05:20:50 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/threads ThreadPool.java

costin      01/10/15 20:20:50

  Modified:    src/share/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Important fix - this rolls back a previous change that disabled recycling.
  
  The thread pool is used to run tasks of the same type. The tasks are initialized
  only once, and the pool provides a 'free' per/thread storage ( i.e. no synchronization,
  O(1) ).
  
  The init() is not supposed to be called on each exacution - otherwise we would
  lose all the recycling.
  
  ( the real fix is just one line, but I also added few flush() for better debugging
  in future )
  
  Revision  Changes    Path
  1.7       +16 -9     jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadPool.java	2001/08/26 01:55:59	1.6
  +++ ThreadPool.java	2001/10/16 03:20:50	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v 1.6 2001/08/26 01:55:59 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 2001/08/26 01:55:59 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v 1.7 2001/10/16 03:20:50 costin Exp $
  + * $Revision: 1.7 $
  + * $Date: 2001/10/16 03:20:50 $
    *
    * ====================================================================
    *
  @@ -383,6 +383,7 @@
   
       void log( String s ) {
   	loghelper.log(s);
  +	loghelper.flush();
       }
       
       /** 
  @@ -419,7 +420,8 @@
                       p.checkSpareControllers();
   
                   } catch(Throwable t) {
  -		    loghelper.log("Unexpected exception", t, Log.ERROR);
  +		    loghelper.log("Unexpected exception", t);
  +		    loghelper.flush();
                   }
               }
           }
  @@ -514,17 +516,18 @@
                           }
   
                           if(shouldRun) {
  -                            toRun.runIt(thData);
  +			    toRun.runIt(thData);
                           }
                       } catch(Throwable t) {
   			loghelper.log("Caught exception executing " + toRun.toString() + ", terminating thread", t);
  +			loghelper.flush();
                           /*
                           * The runnable throw an exception (can be even a ThreadDeath),
                           * signalling that the thread die.
                           *
  -		                * The meaning is that we should release the thread from
  -		                * the pool.
  -		                */
  +			* The meaning is that we should release the thread from
  +			* the pool.
  +			*/
                           shouldTerminate = true;
                           shouldRun = false;
                           p.notifyThreadEnd(this);
  @@ -548,6 +551,7 @@
                   } catch(InterruptedException ie) { /* for the wait operation */
   		    // can never happen, since we don't call interrupt
   		    loghelper.log("Unexpected exception", ie);
  +		    loghelper.flush();
                   }
               }
           }
  @@ -557,7 +561,10 @@
   		throw new NullPointerException("No Runnable");
   	    }
               this.toRun = toRun;
  -            noThData = true;
  +	    // Do not re-init, the whole idea is to run init only once per
  +	    // thread - the pool is supposed to run a single task, that is
  +	    // initialized once.
  +            // noThData = true;
               shouldRun = true;
               this.notify();
           }