Lightweight Cron-Like Scheduling Library for Java
Go to file
Andrew Lalis 020d8e2258 Added demo and updated some javadoc and some mechanics. 2021-04-17 12:51:23 +02:00
src Added demo and updated some javadoc and some mechanics. 2021-04-17 12:51:23 +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 Added basic components. 2021-04-14 17:42:45 +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.