Lightweight Cron-Like Scheduling Library for Java
Go to file
Andrew Lalis 7438c3aa5b Changed to nl.andrewl domain and added DailyScheduleTest 2021-08-06 11:38:31 +02:00
src Changed to nl.andrewl domain and added DailyScheduleTest 2021-08-06 11:38:31 +02:00
.gitignore Added gitignore. 2021-04-16 23:41:16 +02:00
README.md Added more to readme and javadoc. 2021-04-16 23:40:37 +02:00
pom.xml Changed to nl.andrewl domain and added DailyScheduleTest 2021-08-06 11:38:31 +02:00

README.md

Simply Scheduled

This is a very simple cron-like mechanism for scheduling tasks to execute at scheduled points in time. Here's an example:

Runnable job = () -> System.out.println("Doing some work...");
Schedule schedule = new RepeatingSchedule(ChronoUnit.SECONDS, 5);
Scheduler scheduler = new BasicScheduler();
scheduler.add(new Task(job, schedule));
scheduler.start();

In the above example, we create a new job that simply prints a string to standard output. We create a schedule that repeats the task every 5 seconds. Finally, we add the job and schedule together as a Task, add that task to a scheduler, and start the scheduler.

Besides the RepeatingSchedule, this module also includes the following pre-made schedule implementations:

  • DailySchedule - Executes a task once per day, at a specified time.
  • HourlySchedule - Executes a task once per hour, at a specified minute of the hour.
  • MinutelySchedule - Executes a task once per minute, at a specified second.

Extensibility

It is very simple to provide your own custom Schedule implementation if you want a more specific, fine-tuned schedule than what is provided here. Furthermore, you can also provide your own Scheduler implementation, if you prefer to use a different mechanism than the default dynamic thread pool executor service.