org.alfresco.util
Class DynamicallySizedThreadPoolExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.alfresco.util.DynamicallySizedThreadPoolExecutor
All Implemented Interfaces:
java.util.concurrent.Executor, java.util.concurrent.ExecutorService

public class DynamicallySizedThreadPoolExecutor
extends java.util.concurrent.ThreadPoolExecutor

This is an instance of ThreadPoolExecutor which behaves how one would expect it to, even when faced with an unlimited queue. Unlike the default ThreadPoolExecutor, it will add new Threads up to maximumPoolSize when there is lots of pending work, rather than only when the queue is full (which it often never will be, especially for unlimited queues)


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue workQueue)
           
DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue workQueue, java.util.concurrent.RejectedExecutionHandler handler)
           
DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue workQueue, java.util.concurrent.ThreadFactory threadFactory)
           
DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue workQueue, java.util.concurrent.ThreadFactory threadFactory, java.util.concurrent.RejectedExecutionHandler handler)
           
 
Method Summary
protected  void afterExecute(java.lang.Runnable r, java.lang.Throwable t)
           
 void execute(java.lang.Runnable command)
           
 void setCorePoolSize(int corePoolSize)
           
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicallySizedThreadPoolExecutor

public DynamicallySizedThreadPoolExecutor(int corePoolSize,
                                          int maximumPoolSize,
                                          long keepAliveTime,
                                          java.util.concurrent.TimeUnit unit,
                                          java.util.concurrent.BlockingQueue workQueue,
                                          java.util.concurrent.RejectedExecutionHandler handler)

DynamicallySizedThreadPoolExecutor

public DynamicallySizedThreadPoolExecutor(int corePoolSize,
                                          int maximumPoolSize,
                                          long keepAliveTime,
                                          java.util.concurrent.TimeUnit unit,
                                          java.util.concurrent.BlockingQueue workQueue,
                                          java.util.concurrent.ThreadFactory threadFactory,
                                          java.util.concurrent.RejectedExecutionHandler handler)

DynamicallySizedThreadPoolExecutor

public DynamicallySizedThreadPoolExecutor(int corePoolSize,
                                          int maximumPoolSize,
                                          long keepAliveTime,
                                          java.util.concurrent.TimeUnit unit,
                                          java.util.concurrent.BlockingQueue workQueue,
                                          java.util.concurrent.ThreadFactory threadFactory)

DynamicallySizedThreadPoolExecutor

public DynamicallySizedThreadPoolExecutor(int corePoolSize,
                                          int maximumPoolSize,
                                          long keepAliveTime,
                                          java.util.concurrent.TimeUnit unit,
                                          java.util.concurrent.BlockingQueue workQueue)
Method Detail

setCorePoolSize

public void setCorePoolSize(int corePoolSize)
Overrides:
setCorePoolSize in class java.util.concurrent.ThreadPoolExecutor

execute

public void execute(java.lang.Runnable command)
Specified by:
execute in interface java.util.concurrent.Executor
Overrides:
execute in class java.util.concurrent.ThreadPoolExecutor

afterExecute

protected void afterExecute(java.lang.Runnable r,
                            java.lang.Throwable t)
Overrides:
afterExecute in class java.util.concurrent.ThreadPoolExecutor


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.