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 aPausableScheduledThreadPoolExecutor
with core/maximum pool size set to one.PausableScheduledThreadPoolExecutor
(String poolPrefix, int corePoolSize) Create aPausableScheduledThreadPoolExecutor
with specified parameters.PausableScheduledThreadPoolExecutor
(String poolPrefix, int corePoolSize, Consumer<Runnable> afterExecuteFunc) Create aPausableScheduledThreadPoolExecutor
with specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterExecute
(Runnable r, Throwable t) protected void
beforeExecute
(Thread t, Runnable r) boolean
isPaused()
Check if the execution of thisPausableScheduledThreadPoolExecutor
is paused.void
pause()
Pause the execution of thisPausableScheduledThreadPoolExecutor
.void
resume()
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, submit
Methods 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, toString
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
Constructor Details
-
PausableScheduledThreadPoolExecutor
public PausableScheduledThreadPoolExecutor()Create aPausableScheduledThreadPoolExecutor
with core/maximum pool size set to one. -
PausableScheduledThreadPoolExecutor
Create aPausableScheduledThreadPoolExecutor
with specified parameters.- Parameters:
poolPrefix
- prefix name of thread poolcorePoolSize
- core pool size
-
PausableScheduledThreadPoolExecutor
public PausableScheduledThreadPoolExecutor(String poolPrefix, int corePoolSize, Consumer<Runnable> afterExecuteFunc) Create aPausableScheduledThreadPoolExecutor
with 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:
beforeExecute
in classThreadPoolExecutor
-
afterExecute
- Overrides:
afterExecute
in 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 thisPausableScheduledThreadPoolExecutor
is paused.- Returns:
- whether this
PausableScheduledThreadPoolExecutor
is paused.
-