当前页面:
在线文档首页 >
JBoss 4.0.1 sp1 common API Documentation 英文版文档
MinPooledExecutor (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档
org.jboss.util.threadpool
Class MinPooledExecutor
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser
EDU.oswego.cs.dl.util.concurrent.PooledExecutor
org.jboss.util.threadpool.MinPooledExecutor
- All Implemented Interfaces:
- EDU.oswego.cs.dl.util.concurrent.Executor
- public class MinPooledExecutor
- extends EDU.oswego.cs.dl.util.concurrent.PooledExecutor
A pooled executor where the minimum pool size threads are kept alive. This
is needed in order for the waitWhenBlocked option to work because of a
race condition inside the Executor. The race condition goes something like:
RT - Requesting Thread wanting to use the pool
LT - Last Thread in the pool
RT: Check there are enough free threads to process,
yes LT is there, so no need to create a new thread.
LT: Times out on the keep alive, LT is destroyed.
RT: Try to execute, blocks because there are no available threads.
In fact, the pool is now empty which the executor mistakenly
inteprets as all of them being in use.
Doug Lea says he isn't going to fix. In fact, the version in j2se
1.5 doesn't have this option. In order for this to work, the min pool
size must be > 0.
- Version:
- $Revision: 1.3 $
- Author:
- Scott.Stark@jboss.org, adrian@jboss.org
Nested classes inherited from class EDU.oswego.cs.dl.util.concurrent.PooledExecutor |
EDU.oswego.cs.dl.util.concurrent.PooledExecutor.AbortWhenBlocked, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.BlockedExecutionHandler, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.DiscardOldestWhenBlocked, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.DiscardWhenBlocked, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.RunWhenBlocked, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.WaitWhenBlocked, EDU.oswego.cs.dl.util.concurrent.PooledExecutor.Worker |
Nested classes inherited from class EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser |
EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser.DefaultThreadFactory |
Field Summary |
protected int |
keepAliveSize
The number of threads to keep alive threads |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.PooledExecutor |
blockedExecutionHandler_, DEFAULT_KEEPALIVETIME, DEFAULT_MAXIMUMPOOLSIZE, DEFAULT_MINIMUMPOOLSIZE, handOff_, keepAliveTime_, maximumPoolSize_, minimumPoolSize_, poolSize_, shutdown_, threads_ |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser |
threadFactory_ |
Constructor Summary |
MinPooledExecutor(EDU.oswego.cs.dl.util.concurrent.Channel channel,
int poolSize)
Construct a new executor |
MinPooledExecutor(int poolSize)
Construct a new executor |
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.PooledExecutor |
abortWhenBlocked, addThread, awaitTerminationAfterShutdown, awaitTerminationAfterShutdown, createThreads, discardOldestWhenBlocked, discardWhenBlocked, drain, execute, getBlockedExecutionHandler, getKeepAliveTime, getMaximumPoolSize, getMinimumPoolSize, getPoolSize, interruptAll, isTerminatedAfterShutdown, runWhenBlocked, setBlockedExecutionHandler, setKeepAliveTime, setMaximumPoolSize, setMinimumPoolSize, shutdownAfterProcessingCurrentlyQueuedTasks, shutdownAfterProcessingCurrentlyQueuedTasks, shutdownNow, shutdownNow, waitWhenBlocked, workerDone |
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser |
getThreadFactory, setThreadFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
keepAliveSize
protected int keepAliveSize
- The number of threads to keep alive threads
MinPooledExecutor
public MinPooledExecutor(int poolSize)
- Construct a new executor
- Parameters:
poolSize
- the minimum pool size
MinPooledExecutor
public MinPooledExecutor(EDU.oswego.cs.dl.util.concurrent.Channel channel,
int poolSize)
- Construct a new executor
- Parameters:
channel
- the queue for any requestspoolSize
- the minimum pool size
getKeepAliveSize
public int getKeepAliveSize()
- Returns:
- the number of threads to keep alive
setKeepAliveSize
public void setKeepAliveSize(int keepAliveSize)
- Parameters:
keepAliveSize
- the number of threads to keep alive
getTask
protected Runnable getTask()
throws InterruptedException
- Throws:
InterruptedException
keepAlive
protected boolean keepAlive()
- We keep alive unless we are told to shutdown
or there are more than keepAliveSize threads in the pool
- Returns:
- whether to keep alive
Copyright © 2002 JBoss Group, LLC. All Rights Reserved.