Package org.aksw.commons.util.concurrent
Class ScheduleOnce
- java.lang.Object
-
- org.aksw.commons.util.concurrent.ScheduleOnce
-
public class ScheduleOnce extends Object
Class to schedule a task after a certain delay and ensure that it only executes once. If there is a request to schedule the task while it is already running it will be scheduled for the delay.- Author:
- raven
-
-
Field Summary
Fields Modifier and Type Field Description protected java.time.DurationexecDelayprotected java.time.InstantlastExecTimeprotected java.time.InstantlastRequestTimeprotected Objectlockprotected ScheduledExecutorServicescheduledExecutorServiceprotected Callable<?>task
-
Constructor Summary
Constructors Constructor Description ScheduleOnce(ScheduledExecutorService scheduledExecutorService, java.time.Duration execDelay, Callable<?> task)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ScheduleOncescheduleOneTaskAtATime(java.time.Duration execDelay, Callable<?> task)voidscheduleTask()
-
-
-
Field Detail
-
scheduledExecutorService
protected ScheduledExecutorService scheduledExecutorService
-
execDelay
protected java.time.Duration execDelay
-
task
protected Callable<?> task
-
lastRequestTime
protected volatile java.time.Instant lastRequestTime
-
lastExecTime
protected volatile java.time.Instant lastExecTime
-
lock
protected final Object lock
-
-
Constructor Detail
-
ScheduleOnce
public ScheduleOnce(ScheduledExecutorService scheduledExecutorService, java.time.Duration execDelay, Callable<?> task)
-
-
Method Detail
-
scheduleOneTaskAtATime
public static ScheduleOnce scheduleOneTaskAtATime(java.time.Duration execDelay, Callable<?> task)
-
scheduleTask
public void scheduleTask()
-
-