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.DiscardPolicy
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.ThreadPool
org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool
-
Constructor Summary
ConstructorDescriptionVitamThreadPoolExecutor
(int minimumAvailableThreads) Create a Cached Thread PoolVitamThreadPoolExecutor
(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterExecute
(Runnable r, Throwable t) CLean up the session inside the thread.protected void
beforeExecute
(Thread t, Runnable r) Extract VitamSession from the given runnable, and sets it into the target (aka.void
Pass the VitamSession through a VitamRunnable to the target Threadstatic VitamThreadPoolExecutor
Default instanceint
int
boolean
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
-
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:
execute
in interfaceExecutor
- Overrides:
execute
in 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:
beforeExecute
in 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:
afterExecute
in classThreadPoolExecutor
- Parameters:
r
- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)
t
- Cf.ThreadPoolExecutor.beforeExecute(Thread, Runnable)
-
join
- Specified by:
join
in interfaceorg.eclipse.jetty.util.thread.ThreadPool
- Throws:
InterruptedException
-
getThreads
public int getThreads()- Specified by:
getThreads
in interfaceorg.eclipse.jetty.util.thread.ThreadPool
-
getIdleThreads
public int getIdleThreads()- Specified by:
getIdleThreads
in interfaceorg.eclipse.jetty.util.thread.ThreadPool
-
isLowOnThreads
public boolean isLowOnThreads()- Specified by:
isLowOnThreads
in interfaceorg.eclipse.jetty.util.thread.ThreadPool
-