Package fr.gouv.vitam.common.thread
Class VitamThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
fr.gouv.vitam.common.thread.VitamThreadPoolExecutor
- All Implemented Interfaces:
Executor,ExecutorService,org.eclipse.jetty.util.thread.ThreadPool
public class VitamThreadPoolExecutor
extends ThreadPoolExecutor
implements org.eclipse.jetty.util.thread.ThreadPool
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicyNested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.ThreadPool
org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool -
Constructor Summary
ConstructorsConstructorDescriptionVitamThreadPoolExecutor(int minimumAvailableThreads) Create a Cached Thread PoolVitamThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterExecute(Runnable r, Throwable t) CLean up the session inside the thread.protected voidbeforeExecute(Thread t, Runnable r) Extract VitamSession from the given runnable, and sets it into the target (aka.voidPass the VitamSession through a VitamRunnable to the target Threadstatic VitamThreadPoolExecutorDefault instanceintintbooleanvoidjoin()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, toStringMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Details
-
VitamThreadPoolExecutor
public VitamThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<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 Details
-
getDefaultExecutor
Default instance- Returns:
- VitamThreadPoolExecutor instance
-
execute
Pass the VitamSession through a VitamRunnable to the target Thread- Specified by:
executein interfaceExecutor- Overrides:
executein classThreadPoolExecutor- Parameters:
command-
-
beforeExecute
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:
beforeExecutein classThreadPoolExecutor- Parameters:
r- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)t- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)
-
afterExecute
CLean up the session inside the thread.
Carefully see
ThreadPoolExecutor.beforeExecute(Thread, Runnable)documentation, especially about the thread executing this method.- Overrides:
afterExecutein classThreadPoolExecutor- Parameters:
r- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)t- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)
-
join
- Specified by:
joinin interfaceorg.eclipse.jetty.util.thread.ThreadPool- Throws:
InterruptedException
-
getThreads
public int getThreads()- Specified by:
getThreadsin interfaceorg.eclipse.jetty.util.thread.ThreadPool
-
getIdleThreads
public int getIdleThreads()- Specified by:
getIdleThreadsin interfaceorg.eclipse.jetty.util.thread.ThreadPool
-
isLowOnThreads
public boolean isLowOnThreads()- Specified by:
isLowOnThreadsin interfaceorg.eclipse.jetty.util.thread.ThreadPool
-