CronScheduler: a reliable Java scheduler for external interactions

A walk through inconsistencies between different notions of time and the related pitfalls.

Image for post
Image for post

ScheduledThreadPoolExecutor is prone to unbounded clock drift

java.util.Timer freezes periodic tasks or piles them up when system time is shifted

Neither ScheduledThreadPoolExecutor nor Timer take machine suspension into account

Solution: CronScheduler

Schedule periodic tasks at round wall clock times

Skip to latest periodic task runs

Recommendations: which scheduler to use when?

In real code

Where do I get CronScheduler and how to get started?

Software engineer and designer, author. Working at Northvolt.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store