Package org.kquiet.concurrent
Class PausableScheduledThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ScheduledThreadPoolExecutor
org.kquiet.concurrent.PausableScheduledThreadPoolExecutor
- All Implemented Interfaces:
Executor,ExecutorService,ScheduledExecutorService
Pausable
ScheduledThreadPoolExecutor. This class is for internal use.- Author:
- Kimberly
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Constructor Summary
ConstructorsConstructorDescriptionCreate aPausableScheduledThreadPoolExecutorwith core/maximum pool size set to one.PausableScheduledThreadPoolExecutor(String poolPrefix, int corePoolSize) Create aPausableScheduledThreadPoolExecutorwith specified parameters.PausableScheduledThreadPoolExecutor(String poolPrefix, int corePoolSize, Consumer<Runnable> afterExecuteFunc) Create aPausableScheduledThreadPoolExecutorwith specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterExecute(Runnable r, Throwable t) protected voidbeforeExecute(Thread t, Runnable r) booleanisPaused()Check if the execution of thisPausableScheduledThreadPoolExecutoris paused.voidpause()Pause the execution of thisPausableScheduledThreadPoolExecutor.voidresume()Resume the execution of thisPausableScheduledThreadPoolExecutor.Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submitMethods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toStringMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskForMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
Constructor Details
-
PausableScheduledThreadPoolExecutor
public PausableScheduledThreadPoolExecutor()Create aPausableScheduledThreadPoolExecutorwith core/maximum pool size set to one. -
PausableScheduledThreadPoolExecutor
Create aPausableScheduledThreadPoolExecutorwith specified parameters.- Parameters:
poolPrefix- prefix name of thread poolcorePoolSize- core pool size
-
PausableScheduledThreadPoolExecutor
public PausableScheduledThreadPoolExecutor(String poolPrefix, int corePoolSize, Consumer<Runnable> afterExecuteFunc) Create aPausableScheduledThreadPoolExecutorwith specified parameters.- Parameters:
poolPrefix- prefix name of thread poolcorePoolSize- core pool sizeafterExecuteFunc- the function to execute after any task is executed
-
-
Method Details
-
beforeExecute
- Overrides:
beforeExecutein classThreadPoolExecutor
-
afterExecute
- Overrides:
afterExecutein classThreadPoolExecutor
-
pause
public void pause()Pause the execution of thisPausableScheduledThreadPoolExecutor. Any executing task is not affected. -
resume
public void resume()Resume the execution of thisPausableScheduledThreadPoolExecutor. -
isPaused
public boolean isPaused()Check if the execution of thisPausableScheduledThreadPoolExecutoris paused.- Returns:
- whether this
PausableScheduledThreadPoolExecutoris paused.
-