Package atessera.sensei
Class Cron
java.lang.Object
atessera.sensei.Cron
- All Implemented Interfaces:
AutoCloseable
Runs
work() periodically on a dedicated daemon thread.
After each work() invocation the worker sleeps for the configured
number of minutes. close() requests termination without interrupting
an ongoing work() call; if the worker is currently sleeping, it is
woken up so that shutdown does not wait for the whole interval.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Cron
public Cron(int intervalMinutes) Creates and starts a cron worker.- Parameters:
intervalMinutes- sleep interval in minutes; must be positive
-
-
Method Details
-
work
protected void work()Periodic job executed by the worker thread.Subclasses override this method. The default implementation does nothing.
-
close
public void close()Requests the worker thread to stop.The method never interrupts an ongoing
work()call. If the worker is sleeping, it is woken up and finishes as soon as possible.- Specified by:
closein interfaceAutoCloseable
-