Class UnorderedThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.apache.mina.filter.executor.UnorderedThreadPoolExecutor
- All Implemented Interfaces:
Executor, ExecutorService
A
ThreadPoolExecutor that does not maintain the order of IoEvents.
This means more than one event handler methods can be invoked at the same
time with mixed order. For example, let's assume that messageReceived, messageSent,
and sessionClosed events are fired.
- All event handler methods can be called simultaneously. (e.g. messageReceived and messageSent can be invoked at the same time.)
- The event order can be mixed up. (e.g. sessionClosed or messageSent can be invoked before messageReceived is invoked.)
OrderedThreadPoolExecutor.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate intprivate static final Runnableprivate final AtomicIntegerprivate intprivate intprivate final IoEventQueueHandlerprivate booleanprivate final Set<UnorderedThreadPoolExecutor.Worker> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int maximumPoolSize) Creates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize) Creates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit) Creates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory) Creates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, IoEventQueueHandler queueHandler) Creates a new UnorderedThreadPoolExecutor instanceUnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, IoEventQueueHandler queueHandler) Creates a new UnorderedThreadPoolExecutor instance -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidbooleanawaitTermination(long timeout, TimeUnit unit) private voidcheckTaskType(Runnable task) voidintlongintintintintlongbooleanbooleanbooleanintbooleanvoidpurge()private voidrejectTask(Runnable task) booleanprivate voidvoidsetCorePoolSize(int corePoolSize) voidsetMaximumPoolSize(int maximumPoolSize) voidvoidshutdown()Methods inherited from class ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, beforeExecute, finalize, getKeepAliveTime, getQueue, getRejectedExecutionHandler, getThreadFactory, setKeepAliveTime, setThreadFactory, terminated, toStringMethods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Field Details
-
EXIT_SIGNAL
-
workers
-
corePoolSize
private volatile int corePoolSize -
maximumPoolSize
private volatile int maximumPoolSize -
largestPoolSize
private volatile int largestPoolSize -
idleWorkers
-
completedTaskCount
private long completedTaskCount -
shutdown
private volatile boolean shutdown -
queueHandler
-
-
Constructor Details
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor()Creates a new UnorderedThreadPoolExecutor instance -
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int maximumPoolSize) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
maximumPoolSize- The maximum number of threads in the pool
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
corePoolSize- The initial threads pool sizemaximumPoolSize- The maximum number of threads in the pool
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
corePoolSize- The initial threads pool sizemaximumPoolSize- The maximum number of threads in the poolkeepAliveTime- The time to keep threads aliveunit- The time unit for the keepAliveTime
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, IoEventQueueHandler queueHandler) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
corePoolSize- The initial threads pool sizemaximumPoolSize- The maximum number of threads in the poolkeepAliveTime- The time to keep threads aliveunit- The time unit for the keepAliveTimequeueHandler- The Event queue handler to use
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
corePoolSize- The initial threads pool sizemaximumPoolSize- The maximum number of threads in the poolkeepAliveTime- The time to keep threads aliveunit- The time unit for the keepAliveTimethreadFactory- The Thread factory to use
-
UnorderedThreadPoolExecutor
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, IoEventQueueHandler queueHandler) Creates a new UnorderedThreadPoolExecutor instance- Parameters:
corePoolSize- The initial threads pool sizemaximumPoolSize- The maximum number of threads in the poolkeepAliveTime- The time to keep threads aliveunit- The time unit for the keepAliveTimethreadFactory- The Thread factory to usequeueHandler- The Event queue handler to use
-
-
Method Details
-
getQueueHandler
- Returns:
- The Queue handler in use
-
setRejectedExecutionHandler
- Overrides:
setRejectedExecutionHandlerin classThreadPoolExecutor
-
addWorker
private void addWorker() -
addWorkerIfNecessary
private void addWorkerIfNecessary() -
removeWorker
private void removeWorker() -
getMaximumPoolSize
public int getMaximumPoolSize()- Overrides:
getMaximumPoolSizein classThreadPoolExecutor
-
setMaximumPoolSize
public void setMaximumPoolSize(int maximumPoolSize) - Overrides:
setMaximumPoolSizein classThreadPoolExecutor
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Overrides:
awaitTerminationin classThreadPoolExecutor- Throws:
InterruptedException
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService- Overrides:
isShutdownin classThreadPoolExecutor
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService- Overrides:
isTerminatedin classThreadPoolExecutor
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService- Overrides:
shutdownin classThreadPoolExecutor
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService- Overrides:
shutdownNowin classThreadPoolExecutor
-
execute
- Specified by:
executein interfaceExecutor- Overrides:
executein classThreadPoolExecutor
-
rejectTask
-
checkTaskType
-
getActiveCount
public int getActiveCount()- Overrides:
getActiveCountin classThreadPoolExecutor
-
getCompletedTaskCount
public long getCompletedTaskCount()- Overrides:
getCompletedTaskCountin classThreadPoolExecutor
-
getLargestPoolSize
public int getLargestPoolSize()- Overrides:
getLargestPoolSizein classThreadPoolExecutor
-
getPoolSize
public int getPoolSize()- Overrides:
getPoolSizein classThreadPoolExecutor
-
getTaskCount
public long getTaskCount()- Overrides:
getTaskCountin classThreadPoolExecutor
-
isTerminating
public boolean isTerminating()- Overrides:
isTerminatingin classThreadPoolExecutor
-
prestartAllCoreThreads
public int prestartAllCoreThreads()- Overrides:
prestartAllCoreThreadsin classThreadPoolExecutor
-
prestartCoreThread
public boolean prestartCoreThread()- Overrides:
prestartCoreThreadin classThreadPoolExecutor
-
purge
public void purge()- Overrides:
purgein classThreadPoolExecutor
-
remove
- Overrides:
removein classThreadPoolExecutor
-
getCorePoolSize
public int getCorePoolSize()- Overrides:
getCorePoolSizein classThreadPoolExecutor
-
setCorePoolSize
public void setCorePoolSize(int corePoolSize) - Overrides:
setCorePoolSizein classThreadPoolExecutor
-