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:
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
-
-
Constructor Summary
Constructors Constructor Description VitamThreadPoolExecutor()VitamThreadPoolExecutor(int minimumAvailableThreads)Create a Cached Thread PoolVitamThreadPoolExecutor(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 voidafterExecute(java.lang.Runnable r, java.lang.Throwable t)CLean up the session inside the thread.protected voidbeforeExecute(java.lang.Thread t, java.lang.Runnable r)Extract VitamSession from the given runnable, and sets it into the target (aka.voidexecute(java.lang.Runnable command)Pass the VitamSession through a VitamRunnable to the target Threadstatic VitamThreadPoolExecutorgetDefaultExecutor()Default instanceintgetIdleThreads()intgetThreads()booleanisLowOnThreads()voidjoin()-
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
-
-
-
-
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:
executein interfacejava.util.concurrent.Executor- Overrides:
executein classjava.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:
beforeExecutein classjava.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:
afterExecutein classjava.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:
joinin interfaceorg.eclipse.jetty.util.thread.ThreadPool- Throws:
java.lang.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
-
-