Class ThreadPool
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- org.noise_planet.noisemodelling.pathfinder.ThreadPool
-
- All Implemented Interfaces:
Executor
,ExecutorService
public class ThreadPool extends ThreadPoolExecutor
- Author:
- Nicolas Fortin
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description ThreadPool()
Default constructor.ThreadPool(int queueSize)
Default constructor.ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
Size constructor.ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
Size constructor.ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
Size constructor.ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
Size constructor.ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
Size constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeBlocking(Runnable command)
Wait for free queue slot if poolSize is superior or equal of maximum pool size then executes the given task sometime in the future.int
getRemainingTasks()
boolean
hasAvaibleQueueSlot()
void
setProgressVisitor(org.h2gis.api.ProgressVisitor progressVisitor)
<T> Future<T>
submitBlocking(Callable<T> task)
Wait for free queue slot if poolSize is superior or equal of maximum pool size then executes the given task sometime in the future.-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, 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 Detail
-
ThreadPool
public ThreadPool()
Default constructor. Set CorePoolSize size to 32 Set Maximum pool size to 256 Set Keep Alive Time to 60 seconds
-
ThreadPool
public ThreadPool(int queueSize)
Default constructor. Set CorePoolSize size to 32 Set Maximum pool size to 256 Set Keep Alive Time to 60 seconds
-
ThreadPool
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
Size constructor.
-
ThreadPool
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
Size constructor.
-
ThreadPool
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
Size constructor.
-
ThreadPool
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
Size constructor.
-
ThreadPool
public ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
Size constructor.
-
-
Method Detail
-
setProgressVisitor
public void setProgressVisitor(org.h2gis.api.ProgressVisitor progressVisitor)
-
hasAvaibleQueueSlot
public boolean hasAvaibleQueueSlot()
- Returns:
- True if poolSize is inferior of maximum pool size
-
getRemainingTasks
public int getRemainingTasks()
- Returns:
- Remaining threads Running and queued
-
executeBlocking
public void executeBlocking(Runnable command)
Wait for free queue slot if poolSize is superior or equal of maximum pool size then executes the given task sometime in the future. The task may execute in a new thread or in an existing pooled thread. If the task cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been reached, the task is handled by the current RejectedExecutionHandler.- Parameters:
command
-
-
submitBlocking
public <T> Future<T> submitBlocking(Callable<T> task)
Wait for free queue slot if poolSize is superior or equal of maximum pool size then executes the given task sometime in the future. The task may execute in a new thread or in an existing pooled thread. If the task cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been reached, the task is handled by the current RejectedExecutionHandler.
-
-