Class UnorderedThreadPoolExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class UnorderedThreadPoolExecutor
    extends java.util.concurrent.ThreadPoolExecutor
    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.)
    If you need to maintain the order of events per session, please use OrderedThreadPoolExecutor.
    Author:
    Apache MINA Project
    • 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

      Constructors 
      Constructor Description
      UnorderedThreadPoolExecutor()
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int maximumPoolSize)
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize)
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit)
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory)
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory, IoEventQueueHandler queueHandler)
      Creates a new UnorderedThreadPoolExecutor instance
      UnorderedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, IoEventQueueHandler queueHandler)
      Creates a new UnorderedThreadPoolExecutor instance
    • Constructor Detail

      • 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 size
        maximumPoolSize - The maximum number of threads in the pool
      • UnorderedThreadPoolExecutor

        public UnorderedThreadPoolExecutor​(int corePoolSize,
                                           int maximumPoolSize,
                                           long keepAliveTime,
                                           java.util.concurrent.TimeUnit unit)
        Creates a new UnorderedThreadPoolExecutor instance
        Parameters:
        corePoolSize - The initial threads pool size
        maximumPoolSize - The maximum number of threads in the pool
        keepAliveTime - The time to keep threads alive
        unit - The time unit for the keepAliveTime
      • UnorderedThreadPoolExecutor

        public UnorderedThreadPoolExecutor​(int corePoolSize,
                                           int maximumPoolSize,
                                           long keepAliveTime,
                                           java.util.concurrent.TimeUnit unit,
                                           IoEventQueueHandler queueHandler)
        Creates a new UnorderedThreadPoolExecutor instance
        Parameters:
        corePoolSize - The initial threads pool size
        maximumPoolSize - The maximum number of threads in the pool
        keepAliveTime - The time to keep threads alive
        unit - The time unit for the keepAliveTime
        queueHandler - The Event queue handler to use
      • UnorderedThreadPoolExecutor

        public UnorderedThreadPoolExecutor​(int corePoolSize,
                                           int maximumPoolSize,
                                           long keepAliveTime,
                                           java.util.concurrent.TimeUnit unit,
                                           java.util.concurrent.ThreadFactory threadFactory)
        Creates a new UnorderedThreadPoolExecutor instance
        Parameters:
        corePoolSize - The initial threads pool size
        maximumPoolSize - The maximum number of threads in the pool
        keepAliveTime - The time to keep threads alive
        unit - The time unit for the keepAliveTime
        threadFactory - The Thread factory to use
      • UnorderedThreadPoolExecutor

        public UnorderedThreadPoolExecutor​(int corePoolSize,
                                           int maximumPoolSize,
                                           long keepAliveTime,
                                           java.util.concurrent.TimeUnit unit,
                                           java.util.concurrent.ThreadFactory threadFactory,
                                           IoEventQueueHandler queueHandler)
        Creates a new UnorderedThreadPoolExecutor instance
        Parameters:
        corePoolSize - The initial threads pool size
        maximumPoolSize - The maximum number of threads in the pool
        keepAliveTime - The time to keep threads alive
        unit - The time unit for the keepAliveTime
        threadFactory - The Thread factory to use
        queueHandler - The Event queue handler to use
    • Method Detail

      • getQueueHandler

        public IoEventQueueHandler getQueueHandler()
        Returns:
        The Queue handler in use
      • setRejectedExecutionHandler

        public void setRejectedExecutionHandler​(java.util.concurrent.RejectedExecutionHandler handler)
        Overrides:
        setRejectedExecutionHandler in class java.util.concurrent.ThreadPoolExecutor
      • getMaximumPoolSize

        public int getMaximumPoolSize()
        Overrides:
        getMaximumPoolSize in class java.util.concurrent.ThreadPoolExecutor
      • setMaximumPoolSize

        public void setMaximumPoolSize​(int maximumPoolSize)
        Overrides:
        setMaximumPoolSize in class java.util.concurrent.ThreadPoolExecutor
      • awaitTermination

        public boolean awaitTermination​(long timeout,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
        Specified by:
        awaitTermination in interface java.util.concurrent.ExecutorService
        Overrides:
        awaitTermination in class java.util.concurrent.ThreadPoolExecutor
        Throws:
        java.lang.InterruptedException
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface java.util.concurrent.ExecutorService
        Overrides:
        isShutdown in class java.util.concurrent.ThreadPoolExecutor
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface java.util.concurrent.ExecutorService
        Overrides:
        isTerminated in class java.util.concurrent.ThreadPoolExecutor
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface java.util.concurrent.ExecutorService
        Overrides:
        shutdown in class java.util.concurrent.ThreadPoolExecutor
      • shutdownNow

        public java.util.List<java.lang.Runnable> shutdownNow()
        Specified by:
        shutdownNow in interface java.util.concurrent.ExecutorService
        Overrides:
        shutdownNow in class java.util.concurrent.ThreadPoolExecutor
      • execute

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

        public int getActiveCount()
        Overrides:
        getActiveCount in class java.util.concurrent.ThreadPoolExecutor
      • getCompletedTaskCount

        public long getCompletedTaskCount()
        Overrides:
        getCompletedTaskCount in class java.util.concurrent.ThreadPoolExecutor
      • getLargestPoolSize

        public int getLargestPoolSize()
        Overrides:
        getLargestPoolSize in class java.util.concurrent.ThreadPoolExecutor
      • getPoolSize

        public int getPoolSize()
        Overrides:
        getPoolSize in class java.util.concurrent.ThreadPoolExecutor
      • getTaskCount

        public long getTaskCount()
        Overrides:
        getTaskCount in class java.util.concurrent.ThreadPoolExecutor
      • isTerminating

        public boolean isTerminating()
        Overrides:
        isTerminating in class java.util.concurrent.ThreadPoolExecutor
      • prestartAllCoreThreads

        public int prestartAllCoreThreads()
        Overrides:
        prestartAllCoreThreads in class java.util.concurrent.ThreadPoolExecutor
      • prestartCoreThread

        public boolean prestartCoreThread()
        Overrides:
        prestartCoreThread in class java.util.concurrent.ThreadPoolExecutor
      • purge

        public void purge()
        Overrides:
        purge in class java.util.concurrent.ThreadPoolExecutor
      • remove

        public boolean remove​(java.lang.Runnable task)
        Overrides:
        remove in class java.util.concurrent.ThreadPoolExecutor
      • getCorePoolSize

        public int getCorePoolSize()
        Overrides:
        getCorePoolSize in class java.util.concurrent.ThreadPoolExecutor
      • setCorePoolSize

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