Class UnorderedThreadPoolExecutor

All Implemented Interfaces:
Executor, ExecutorService

public class UnorderedThreadPoolExecutor extends 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.
  • Field Details

    • EXIT_SIGNAL

      private static final Runnable EXIT_SIGNAL
    • workers

      private final Set<UnorderedThreadPoolExecutor.Worker> workers
    • corePoolSize

      private volatile int corePoolSize
    • maximumPoolSize

      private volatile int maximumPoolSize
    • largestPoolSize

      private volatile int largestPoolSize
    • idleWorkers

      private final AtomicInteger idleWorkers
    • completedTaskCount

      private long completedTaskCount
    • shutdown

      private volatile boolean shutdown
    • queueHandler

      private final IoEventQueueHandler 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 size
      maximumPoolSize - 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 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, 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, TimeUnit unit, 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, TimeUnit unit, 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 Details