Constructor and Description |
---|
PeriodicTimer(ScheduledExecutorService executorService)
Initializes a new instance of the
PeriodicTimer class. |
Modifier and Type | Method and Description |
---|---|
void |
schedule(org.joda.time.Duration initialDelay,
org.joda.time.Duration period)
Schedules a periodic event with specified
initialDelay and period . |
void |
scheduleOneShot(org.joda.time.Duration delay)
Schedules an one-time event to be trigger after time interval specified by passed
Duration . |
void |
setListener(TimerListener listener)
Sets the
TimerListener observation used to observe this Timer implementation |
void |
stop()
Un-schedules any events previously registered with calls to
Timer.scheduleOneShot(org.joda.time.Duration)
or Timer.schedule(org.joda.time.Duration, org.joda.time.Duration) . |
public PeriodicTimer(ScheduledExecutorService executorService)
PeriodicTimer
class.IllegalArgumentException
- The executorService
is a null reference or initialDelay
is smaller than zero or period
is smaller than or equal to zero.public void setListener(TimerListener listener)
TimerListener
observation used to observe this Timer
implementationsetListener
in interface Timer
listener
- The TimerListener
instance used to observe this Timer
or a null reference.public void scheduleOneShot(org.joda.time.Duration delay)
Duration
.
Any events scheduled by previous calls to either Timer.scheduleOneShot(org.joda.time.Duration)
or
Timer.schedule(org.joda.time.Duration, org.joda.time.Duration)
are un-scheduled by this call.scheduleOneShot
in interface Timer
delay
- Specifies the time interval after which the one shot event will be triggered.IllegalArgumentException
- The delay
is a null reference.public void schedule(org.joda.time.Duration initialDelay, org.joda.time.Duration period)
initialDelay
and period
.
Any events scheduled by previous calls to either Timer.scheduleOneShot(org.joda.time.Duration)
or
Timer.schedule(org.joda.time.Duration, org.joda.time.Duration)
are un-scheduled by this call.schedule
in interface Timer
initialDelay
- Specifies the time interval after which the one shot event will be triggered.period
- Specifies the timer period.IllegalArgumentException
- The initialDelay
is a null reference or
period
is a null reference.public void stop()
Timer.scheduleOneShot(org.joda.time.Duration)
or Timer.schedule(org.joda.time.Duration, org.joda.time.Duration)
. If no events were scheduled it does
nothing.Copyright © 2013–2023. All rights reserved.