Fix for 43642.
authorjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Apr 2010 12:55:19 +0000 (12:55 +0000)
committerjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Apr 2010 12:55:19 +0000 (12:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@936289 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardThreadExecutor.java
webapps/docs/changelog.xml
webapps/docs/config/executor.xml

index c78bc2d..3b9a5d6 100644 (file)
@@ -74,6 +74,11 @@ public class StandardThreadExecutor extends LifecycleBase
     protected String name;
     
     /**
+     * prestart threads?
+     */
+    protected boolean prestartminSpareThreads = false;
+
+    /**
      * The maximum number of elements that can queue up before we reject them
      */
     protected int maxQueueSize = Integer.MAX_VALUE;
@@ -101,6 +106,9 @@ public class StandardThreadExecutor extends LifecycleBase
         taskqueue = new TaskQueue(maxQueueSize);
         TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
         executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
+        if (prestartminSpareThreads) {
+            executor.prestartAllCoreThreads();
+        }
         taskqueue.setParent(executor);
 
         setState(LifecycleState.STARTING);
@@ -172,6 +180,10 @@ public class StandardThreadExecutor extends LifecycleBase
         return name;
     }
 
+    public boolean isPrestartminSpareThreads() {
+
+        return prestartminSpareThreads;
+    }
     public void setThreadPriority(int threadPriority) {
         this.threadPriority = threadPriority;
     }
@@ -205,6 +217,10 @@ public class StandardThreadExecutor extends LifecycleBase
         }
     }
 
+    public void setPrestartminSpareThreads(boolean prestartminSpareThreads) {
+        this.prestartminSpareThreads = prestartminSpareThreads;
+    }
+
     public void setName(String name) {
         this.name = name;
     }
index efc56e1..a02c484 100644 (file)
@@ -35,6 +35,9 @@
 <section name="Tomcat 7.0.0 (markt)">
   <subsection name="Catalina">
     <changelog>
+      <add>
+        <bug>43642</bug>: Add prestartminSpareThreads attribute for Executor. (jfclere)
+      </add>
       <update>
         Update Servlet support to the Servlet 3.0 specification. Note
         asynchronous support is not yet complete. (markt/fhanik)
index 05759a5..41fe737 100644 (file)
       <p>(int) The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less
          or equal to minSpareThreads. Default value is <code>60000</code>(1 minute)</p>
     </attribute>
+    <attribute name="prestartminSpareThreads" required="false">
+      <p>(boolean) Whether minSpareThreads should be started when starting the Executor or not,
+          the default is <code>false</code></p>
+    </attribute>
   </attributes>