public class ThreadMonitor extends Object implements ThreadExecutor
ThreadExecutor
proxy used to track threads. Its purpose is to be
used for debugging at development phase, it should not be used at
production code.Modifier and Type | Class and Description |
---|---|
static class |
ThreadMonitor.ThreadExecutionState
Thread execution state.
|
static interface |
ThreadMonitor.ThreadListener
Thread listener.
|
Constructor and Description |
---|
ThreadMonitor(ThreadExecutor delegate,
ThreadMonitor.ThreadListener threadListener,
javax.measure.Measurable<javax.measure.quantity.Duration> activeThreadsStateUpdateFrequency)
Creates a new thread monitor.
|
Modifier and Type | Method and Description |
---|---|
<T> ScheduledFuture<T> |
schedule(Callable<T> task,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
ScheduledFuture<?> |
schedule(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
Date initialTime,
javax.measure.Measurable<javax.measure.quantity.Duration> period)
For the sake of cancellability but not provide a usable result Creates
and executes a periodic action that becomes enabled first at the given
initial time, and subsequently with the given period; that is
executions will commence at initialTime then initialTime+period, then
initialTime + 2 * period, and so on.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay,
javax.measure.Measurable<javax.measure.quantity.Duration> period)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given period; that
is executions will commence after initialDelay then
initialDelay+period, then initialDelay + 2 * period, and so on.
|
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay,
javax.measure.Measurable<javax.measure.quantity.Duration> delay)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given delay between
the termination of one execution and the commencement of the next.
|
<T> Future<T> |
submit(Callable<T> task)
This method is used to decouple execution of task i.e.
|
Future<?> |
submit(Runnable task)
This method is use to decouple execution of task i.e.
|
public ThreadMonitor(ThreadExecutor delegate, ThreadMonitor.ThreadListener threadListener, javax.measure.Measurable<javax.measure.quantity.Duration> activeThreadsStateUpdateFrequency)
delegate
- delegatethreadListener
- listener to handle thread monitoring, see
LoggerThreadListener
activeThreadsStateUpdateFrequency
- frequency to update active
threads state, null
to not track active threads state at
all. If null
is used the executing() method in
ThreadListener won't be called.public Future<?> submit(Runnable task)
RunnableExecutor
submit
in interface RunnableExecutor
task
- task to be executedpublic <T> Future<T> submit(Callable<T> task)
CallableExecutor
submit
in interface CallableExecutor
T
- type of the execution resulttask
- task to be executedpublic ScheduledFuture<?> schedule(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
schedule
in interface ThreadExecutor
task
- the runnable task to be executeddelay
- the time from now to delay executionpublic <T> ScheduledFuture<T> schedule(Callable<T> task, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
schedule
in interface ThreadExecutor
T
- the type of the execution resulttask
- the task to be executeddelay
- the time from now to delay executionpublic ScheduledFuture<?> scheduleAtFixedRate(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay, javax.measure.Measurable<javax.measure.quantity.Duration> period)
ThreadExecutor
scheduleAtFixedRate
in interface ThreadExecutor
task
- the task to be executedinitialDelay
- the time to delay first executionperiod
- the period between successive executionspublic ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date initialTime, javax.measure.Measurable<javax.measure.quantity.Duration> period) throws IllegalArgumentException
ThreadExecutor
scheduleAtFixedRate
in interface ThreadExecutor
task
- the task to be executedinitialTime
- the time of the first executionperiod
- the period between successive executionsIllegalArgumentException
- if initialTime is in the pastpublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, javax.measure.Measurable<javax.measure.quantity.Duration> initialDelay, javax.measure.Measurable<javax.measure.quantity.Duration> delay)
ThreadExecutor
scheduleWithFixedDelay
in interface ThreadExecutor
task
- the task to be executedinitialDelay
- the time to delay first execution.delay
- the delay between the termination of one execution and the
commencement of the nextCopyright © 2015. All Rights Reserved.