public class ThreadRenamingSchedulerService extends ThreadRenamingSubmitterScheduler implements SchedulerService
SchedulerService
and wraps all supplied tasks in a
ThreadRenamingRunnable
. This allows you to make a pool where all tasks submitted
inside it have the threads named in an identifiable way.Constructor and Description |
---|
ThreadRenamingSchedulerService(SchedulerService scheduler,
java.lang.String threadName,
boolean replace)
Constructs a new
ThreadRenamingSchedulerService , wrapping a supplied
SchedulerService . |
Modifier and Type | Method and Description |
---|---|
int |
getActiveTaskCount()
Call to check how many tasks are currently being executed in this scheduler.
|
int |
getQueuedTaskCount()
Returns how many tasks are either waiting to be executed, or are scheduled to be executed at
a future point.
|
int |
getWaitingForExecutionTaskCount()
Returns how many tasks are either waiting to be executed.
|
boolean |
isShutdown()
Function to check if the thread pool is currently accepting and handling tasks.
|
boolean |
remove(java.util.concurrent.Callable<?> task)
Removes the callable task from the execution queue.
|
boolean |
remove(java.lang.Runnable task)
Removes the runnable task from the execution queue.
|
scheduleAtFixedRate, scheduleWithFixedDelay
schedule, submitScheduled, submitScheduled
execute, submit, submit
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
schedule, scheduleAtFixedRate, scheduleWithFixedDelay, submitScheduled, submitScheduled, submitScheduled
submit, submit, submit
public ThreadRenamingSchedulerService(SchedulerService scheduler, java.lang.String threadName, boolean replace)
ThreadRenamingSchedulerService
, wrapping a supplied
SchedulerService
. If /replace
is false
the thread will be named such
that threadName[originalThreadName]
.scheduler
- SchedulerService to wrap and send executions tothreadName
- Thread name prefix, or replaced namereplace
- If true
the original name wont be included in the thread namepublic boolean remove(java.lang.Runnable task)
SchedulerService
Note that this call has high guarantees on the ability to remove the task (as in a complete guarantee). But while this is being invoked, it will reduce the throughput of execution, so should NOT be used extremely frequently.
For non-recurring tasks using a future and calling
Future.cancel(boolean)
can be a better solution.
remove
in interface SchedulerService
task
- The original runnable provided to the executortrue
if the runnable was found and removedpublic boolean remove(java.util.concurrent.Callable<?> task)
SchedulerService
Note that this call has high guarantees on the ability to remove the task (as in a complete guarantee). But while this is being invoked, it will reduce the throughput of execution, so should NOT be used extremely frequently.
For non-recurring tasks using a future and calling
Future.cancel(boolean)
can be a better solution.
remove
in interface SchedulerService
task
- The original callable provided to the executortrue
if the callable was found and removedpublic int getActiveTaskCount()
SchedulerService
getActiveTaskCount
in interface SchedulerService
public int getQueuedTaskCount()
SchedulerService
SchedulerService.getWaitingForExecutionTaskCount()
.getQueuedTaskCount
in interface SchedulerService
public int getWaitingForExecutionTaskCount()
SchedulerService
getWaitingForExecutionTaskCount
in interface SchedulerService
public boolean isShutdown()
SchedulerService
isShutdown
in interface SchedulerService
true
if thread pool is running