Class VitamThreadPoolExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService, org.eclipse.jetty.util.thread.ThreadPool

    public class VitamThreadPoolExecutor
    extends java.util.concurrent.ThreadPoolExecutor
    implements org.eclipse.jetty.util.thread.ThreadPool
    • 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
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.ThreadPool

        org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool
    • Constructor Summary

      Constructors 
      Constructor Description
      VitamThreadPoolExecutor()  
      VitamThreadPoolExecutor​(int minimumAvailableThreads)
      Create a Cached Thread Pool
      VitamThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void afterExecute​(java.lang.Runnable r, java.lang.Throwable t)
      CLean up the session inside the thread.
      protected void beforeExecute​(java.lang.Thread t, java.lang.Runnable r)
      Extract VitamSession from the given runnable, and sets it into the target (aka.
      void execute​(java.lang.Runnable command)
      Pass the VitamSession through a VitamRunnable to the target Thread
      static VitamThreadPoolExecutor getDefaultExecutor()
      Default instance
      int getIdleThreads()  
      int getThreads()  
      boolean isLowOnThreads()  
      void join()  
      • Methods inherited from class java.util.concurrent.ThreadPoolExecutor

        allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • VitamThreadPoolExecutor

        public VitamThreadPoolExecutor​(int corePoolSize,
                                       int maximumPoolSize,
                                       long keepAliveTime,
                                       java.util.concurrent.TimeUnit unit,
                                       java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
      • VitamThreadPoolExecutor

        public VitamThreadPoolExecutor()
      • VitamThreadPoolExecutor

        public VitamThreadPoolExecutor​(int minimumAvailableThreads)
        Create a Cached Thread Pool
        Parameters:
        minimumAvailableThreads - minimum Available Threads kept in the pool
    • Method Detail

      • getDefaultExecutor

        public static VitamThreadPoolExecutor getDefaultExecutor()
        Default instance
        Returns:
        VitamThreadPoolExecutor instance
      • execute

        public void execute​(java.lang.Runnable command)
        Pass the VitamSession through a VitamRunnable to the target Thread
        Specified by:
        execute in interface java.util.concurrent.Executor
        Overrides:
        execute in class java.util.concurrent.ThreadPoolExecutor
        Parameters:
        command -
      • beforeExecute

        protected void beforeExecute​(java.lang.Thread t,
                                     java.lang.Runnable r)

        Extract VitamSession from the given runnable, and sets it into the target (aka. current) Thread.

        Carefully see ThreadPoolExecutor.beforeExecute(Thread, Runnable) documentation, especially about the thread executing this method.

        Overrides:
        beforeExecute in class java.util.concurrent.ThreadPoolExecutor
        Parameters:
        r - Cf. ThreadPoolExecutor.beforeExecute(Thread, Runnable)
        t - Cf. ThreadPoolExecutor.beforeExecute(Thread, Runnable)
      • afterExecute

        protected void afterExecute​(java.lang.Runnable r,
                                    java.lang.Throwable t)

        CLean up the session inside the thread.

        Carefully see ThreadPoolExecutor.beforeExecute(Thread, Runnable) documentation, especially about the thread executing this method.

        Overrides:
        afterExecute in class java.util.concurrent.ThreadPoolExecutor
        Parameters:
        r - Cf. ThreadPoolExecutor.beforeExecute(Thread, Runnable)
        t - Cf. ThreadPoolExecutor.beforeExecute(Thread, Runnable)
      • join

        public void join()
                  throws java.lang.InterruptedException
        Specified by:
        join in interface org.eclipse.jetty.util.thread.ThreadPool
        Throws:
        java.lang.InterruptedException
      • getThreads

        public int getThreads()
        Specified by:
        getThreads in interface org.eclipse.jetty.util.thread.ThreadPool
      • getIdleThreads

        public int getIdleThreads()
        Specified by:
        getIdleThreads in interface org.eclipse.jetty.util.thread.ThreadPool
      • isLowOnThreads

        public boolean isLowOnThreads()
        Specified by:
        isLowOnThreads in interface org.eclipse.jetty.util.thread.ThreadPool