Class ExecutorThreadPool

    • Constructor Detail

      • ExecutorThreadPool

        public ExecutorThreadPool()
      • ExecutorThreadPool

        public ExecutorThreadPool​(int maxThreads)
      • ExecutorThreadPool

        public ExecutorThreadPool​(int maxThreads,
                                  int minThreads)
      • ExecutorThreadPool

        public ExecutorThreadPool​(int maxThreads,
                                  int minThreads,
                                  java.util.concurrent.BlockingQueue<java.lang.Runnable> queue)
      • ExecutorThreadPool

        public ExecutorThreadPool​(java.util.concurrent.ThreadPoolExecutor executor)
      • ExecutorThreadPool

        public ExecutorThreadPool​(java.util.concurrent.ThreadPoolExecutor executor,
                                  int reservedThreads)
      • ExecutorThreadPool

        public ExecutorThreadPool​(java.util.concurrent.ThreadPoolExecutor executor,
                                  int reservedThreads,
                                  java.lang.ThreadGroup group)
    • Method Detail

      • getName

        @ManagedAttribute("name of this thread pool")
        public java.lang.String getName()
        Returns:
        the name of the this thread pool
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name - the name of this thread pool, used to name threads
      • getIdleTimeout

        @ManagedAttribute("maximum time a thread may be idle in ms")
        public int getIdleTimeout()
        Returns:
        the maximum thread idle time in ms.
        See Also:
        setIdleTimeout(int)
      • setIdleTimeout

        public void setIdleTimeout​(int idleTimeout)

        Sets the maximum thread idle time in ms.

        Threads that are idle for longer than this period may be stopped.

        Parameters:
        idleTimeout - the maximum thread idle time in ms.
        See Also:
        getIdleTimeout()
      • getReservedThreads

        @ManagedAttribute("the number of reserved threads in the pool")
        public int getReservedThreads()
        Returns:
        number of reserved threads or -1 to indicate that the number is heuristically determined
        See Also:
        setReservedThreads(int)
      • setReservedThreads

        public void setReservedThreads​(int reservedThreads)
        Sets the number of reserved threads.
        Parameters:
        reservedThreads - number of reserved threads or -1 to determine the number heuristically
        See Also:
        getReservedThreads()
      • setThreadsPriority

        public void setThreadsPriority​(int priority)
      • getThreadsPriority

        public int getThreadsPriority()
      • isDaemon

        @ManagedAttribute("whether this thread pool uses daemon threads")
        public boolean isDaemon()
        Returns:
        whether this thread pool uses daemon threads
        See Also:
        setDaemon(boolean)
      • setDaemon

        public void setDaemon​(boolean daemon)
        Parameters:
        daemon - whether this thread pool uses daemon threads
        See Also:
        Thread.setDaemon(boolean)
      • isDetailedDump

        @ManagedAttribute("reports additional details in the dump")
        public boolean isDetailedDump()
      • setDetailedDump

        public void setDetailedDump​(boolean detailedDump)
      • getThreads

        @ManagedAttribute("number of threads in the pool")
        public int getThreads()
        Specified by:
        getThreads in interface ThreadPool
        Returns:
        The total number of threads currently in the pool
      • getIdleThreads

        @ManagedAttribute("number of idle threads in the pool")
        public int getIdleThreads()
        Specified by:
        getIdleThreads in interface ThreadPool
        Returns:
        The number of idle threads in the pool
      • execute

        public void execute​(java.lang.Runnable command)
        Specified by:
        execute in interface java.util.concurrent.Executor
        Specified by:
        execute in interface TryExecutor
      • tryExecute

        public boolean tryExecute​(java.lang.Runnable task)
        Description copied from interface: TryExecutor
        Attempt to execute a task.
        Specified by:
        tryExecute in interface TryExecutor
        Parameters:
        task - The task to be executed
        Returns:
        True IFF the task has been given directly to a thread to execute. The task cannot be queued pending the later availability of a Thread.
      • join

        public void join()
                  throws java.lang.InterruptedException
        Description copied from interface: ThreadPool
        Blocks until the thread pool is stopped.
        Specified by:
        join in interface ThreadPool
        Throws:
        java.lang.InterruptedException - if thread was interrupted
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Description copied from interface: Dumpable
        Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
        Specified by:
        dump in interface Dumpable
        Overrides:
        dump in class ContainerLifeCycle
        Parameters:
        out - The appendable to dump to
        indent - The indent to apply after any new lines.
        Throws:
        java.io.IOException - if unable to write to Appendable