Author: fhanik Date: Mon Aug 24 19:58:23 2009 New Revision: 807358 URL: http://svn.apache.org/viewvc?rev=807358&view=rev Log: Add in option to resize thread pool
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java Modified: tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java?rev=807358&r1=807357&r2=807358&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java Mon Aug 24 19:58:23 2009 @@ -24,11 +24,12 @@ import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleListener; import org.apache.catalina.util.LifecycleSupport; +import org.apache.tomcat.util.threads.ResizableExecutor; import org.apache.tomcat.util.threads.TaskQueue; import org.apache.tomcat.util.threads.TaskThreadFactory; import org.apache.tomcat.util.threads.ThreadPoolExecutor; -public class StandardThreadExecutor implements Executor { +public class StandardThreadExecutor implements Executor, ResizableExecutor { // ---------------------------------------------- Properties /** @@ -77,6 +78,8 @@ protected int maxQueueSize = Integer.MAX_VALUE; private LifecycleSupport lifecycle = new LifecycleSupport(this); + + private TaskQueue taskqueue = null; // ---------------------------------------------- Constructors public StandardThreadExecutor() { //empty constructor for the digester @@ -87,7 +90,7 @@ // ---------------------------------------------- Public Methods public void start() throws LifecycleException { lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null); - TaskQueue taskqueue = new TaskQueue(maxQueueSize); + taskqueue = new TaskQueue(maxQueueSize); TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority()); lifecycle.fireLifecycleEvent(START_EVENT, null); executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf); @@ -100,6 +103,7 @@ lifecycle.fireLifecycleEvent(STOP_EVENT, null); if ( executor != null ) executor.shutdownNow(); executor = null; + taskqueue = null; lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null); } @@ -249,4 +253,27 @@ public int getQueueSize() { return (executor != null) ? executor.getQueue().size() : -1; } + + + + @Override + public boolean resizePool(int corePoolSize, int maximumPoolSize) { + if (executor == null) { + return false; + } else { + executor.setCorePoolSize(corePoolSize); + executor.setMaximumPoolSize(maximumPoolSize); + return true; + } + } + + + + @Override + public boolean resizeQueue(int capacity) { + return false; + } + + + } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org