Class ThreadPool
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.noise_planet.noisemodelling.pathfinder.ThreadPool
- All Implemented Interfaces:
AutoCloseable,Executor,ExecutorService
- 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
ConstructorsConstructorDescriptionDefault 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
Modifier and TypeMethodDescriptionvoidexecuteBlocking(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.intbooleanvoidsetProgressVisitor(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, toStringMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
close
-
Constructor Details
-
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
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 Details
-
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
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
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.
-