Class StandardThreadExecutor

    • Field Detail

      • sm

        protected static final StringManager sm
        StringManager for this package.
      • threadPriority

        protected int threadPriority
        Default thread priority
      • daemon

        protected boolean daemon
        Run threads in daemon or non-daemon state
      • namePrefix

        protected java.lang.String namePrefix
        Default name prefix for the thread name
      • maxThreads

        protected int maxThreads
        max number of threads
      • minSpareThreads

        protected int minSpareThreads
        min number of threads
      • maxIdleTime

        protected int maxIdleTime
        idle time in milliseconds
      • name

        protected java.lang.String name
        the name of this thread pool
      • maxQueueSize

        protected int maxQueueSize
        The maximum number of elements that can queue up before we reject them
      • threadRenewalDelay

        protected long threadRenewalDelay
        After a context is stopped, threads in the pool are renewed. To avoid renewing all threads at the same time, this delay is observed between 2 threads being renewed.
    • Constructor Detail

      • StandardThreadExecutor

        public StandardThreadExecutor()
        Default constructor required for the Digester.
    • Method Detail

      • execute

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

        public void contextStopping()
        Notify the underlying executor that the associated context is stopping so that it can prepare for shutdown.
      • getThreadPriority

        public int getThreadPriority()
        Return the thread priority for new threads.
        Returns:
        the thread priority
      • isDaemon

        public boolean isDaemon()
        Return whether threads are daemon threads.
        Returns:
        true if threads are daemon threads
      • getNamePrefix

        public java.lang.String getNamePrefix()
        Return the name prefix for new threads.
        Returns:
        the name prefix
      • getMaxIdleTime

        public int getMaxIdleTime()
        Return the maximum idle time in milliseconds.
        Returns:
        the maximum idle time in milliseconds
      • getMaxThreads

        public int getMaxThreads()
        Description copied from interface: ResizableExecutor
        Returns the maximum number of threads in the pool.
        Specified by:
        getMaxThreads in interface ResizableExecutor
        Returns:
        the maximum number of threads
      • getMinSpareThreads

        public int getMinSpareThreads()
        Return the minimum number of spare threads.
        Returns:
        the minimum spare threads
      • getName

        public java.lang.String getName()
        Description copied from interface: Executor
        Returns the name of this executor.
        Specified by:
        getName in interface Executor
        Returns:
        the executor name
      • setThreadPriority

        public void setThreadPriority​(int threadPriority)
        Set the thread priority for new threads.
        Parameters:
        threadPriority - the thread priority
      • setDaemon

        public void setDaemon​(boolean daemon)
        Set whether threads are daemon threads.
        Parameters:
        daemon - true for daemon threads
      • setNamePrefix

        public void setNamePrefix​(java.lang.String namePrefix)
        Set the name prefix for new threads.
        Parameters:
        namePrefix - the name prefix
      • setMaxIdleTime

        public void setMaxIdleTime​(int maxIdleTime)
        Set the maximum idle time in milliseconds.
        Parameters:
        maxIdleTime - the maximum idle time
      • setMaxThreads

        public void setMaxThreads​(int maxThreads)
        Set the maximum number of threads in the pool.
        Parameters:
        maxThreads - the maximum threads
      • setMinSpareThreads

        public void setMinSpareThreads​(int minSpareThreads)
        Set the minimum number of spare threads.
        Parameters:
        minSpareThreads - the minimum spare threads
      • setName

        public void setName​(java.lang.String name)
        Set the name for this executor.
        Parameters:
        name - the executor name
      • setMaxQueueSize

        public void setMaxQueueSize​(int size)
        Set the maximum queue size.
        Parameters:
        size - the maximum queue size
      • getMaxQueueSize

        public int getMaxQueueSize()
        Return the maximum number of elements that can queue up before tasks are rejected.
        Returns:
        the maximum queue size
      • getThreadRenewalDelay

        public long getThreadRenewalDelay()
        Return the thread renewal delay in milliseconds.
        Returns:
        the thread renewal delay
      • setThreadRenewalDelay

        public void setThreadRenewalDelay​(long threadRenewalDelay)
        Set the thread renewal delay in milliseconds.
        Parameters:
        threadRenewalDelay - the thread renewal delay
      • getActiveCount

        public int getActiveCount()
        Description copied from interface: ResizableExecutor
        Returns the approximate number of threads that are actively executing tasks.
        Specified by:
        getActiveCount in interface ResizableExecutor
        Returns:
        the number of threads
      • getCompletedTaskCount

        public long getCompletedTaskCount()
        Return the approximate total number of tasks that have completed execution.
        Returns:
        the completed task count
      • getCorePoolSize

        public int getCorePoolSize()
        Return the core number of threads for the underlying thread pool.
        Returns:
        the core pool size
      • getLargestPoolSize

        public int getLargestPoolSize()
        Return the largest number of threads that have ever simultaneously been in the pool.
        Returns:
        the largest pool size
      • getPoolSize

        public int getPoolSize()
        Description copied from interface: ResizableExecutor
        Returns the current number of threads in the pool.
        Specified by:
        getPoolSize in interface ResizableExecutor
        Returns:
        the number of threads
      • getQueueSize

        public int getQueueSize()
        Return the current queue size.
        Returns:
        the queue size, or -1 if not available
      • resizePool

        public boolean resizePool​(int corePoolSize,
                                  int maximumPoolSize)
        Description copied from interface: ResizableExecutor
        Resize the thread pool.
        Specified by:
        resizePool in interface ResizableExecutor
        Parameters:
        corePoolSize - The new core pool size
        maximumPoolSize - The new maximum pool size
        Returns:
        True if the pool was resized successfully
      • resizeQueue

        public boolean resizeQueue​(int capacity)
        Description copied from interface: ResizableExecutor
        Resize the work queue.
        Specified by:
        resizeQueue in interface ResizableExecutor
        Parameters:
        capacity - The new queue capacity
        Returns:
        True if the queue was resized successfully
      • getDomainInternal

        protected java.lang.String getDomainInternal()
        Description copied from class: LifecycleMBeanBase
        Method implemented by subclasses to identify the domain in which MBeans should be registered.
        Specified by:
        getDomainInternal in class LifecycleMBeanBase
        Returns:
        The name of the domain to use to register MBeans.
      • getObjectNameKeyProperties

        protected java.lang.String getObjectNameKeyProperties()
        Description copied from class: LifecycleMBeanBase
        Allow subclasses to specify the key properties component of the ObjectName that will be used to register this component.
        Specified by:
        getObjectNameKeyProperties in class LifecycleMBeanBase
        Returns:
        The string representation of the key properties component of the desired ObjectName
      • shutdown

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

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

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

        public boolean isTerminated()
        Specified by:
        isTerminated in interface java.util.concurrent.ExecutorService
      • awaitTermination

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

        public <T> java.util.concurrent.Future<T> submit​(java.util.concurrent.Callable<T> task)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
      • submit

        public <T> java.util.concurrent.Future<T> submit​(java.lang.Runnable task,
                                                         T result)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
      • submit

        public java.util.concurrent.Future<?> submit​(java.lang.Runnable task)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
      • invokeAll

        public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                                                                     throws java.lang.InterruptedException
        Specified by:
        invokeAll in interface java.util.concurrent.ExecutorService
        Throws:
        java.lang.InterruptedException
      • invokeAll

        public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                            long timeout,
                                                                            java.util.concurrent.TimeUnit unit)
                                                                     throws java.lang.InterruptedException
        Specified by:
        invokeAll in interface java.util.concurrent.ExecutorService
        Throws:
        java.lang.InterruptedException
      • invokeAny

        public <T> T invokeAny​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                        throws java.lang.InterruptedException,
                               java.util.concurrent.ExecutionException
        Specified by:
        invokeAny in interface java.util.concurrent.ExecutorService
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • invokeAny

        public <T> T invokeAny​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                               long timeout,
                               java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException,
                               java.util.concurrent.ExecutionException,
                               java.util.concurrent.TimeoutException
        Specified by:
        invokeAny in interface java.util.concurrent.ExecutorService
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException