-
Notifications
You must be signed in to change notification settings - Fork 0
Core Concepts
frosxt edited this page Jan 20, 2026
·
1 revision
The Scheduler is the main entry point. It manages a pool of worker threads and orchestrates task execution.
-
Thread Pool: Configurable size via
SchedulerSpec.threadCount(). -
Time Source: Uses monotonic time (
System.nanoTime()) for duration calculations to be immune to system clock shifts. -
Lifecycle: Must be closed via
close()to terminate worker threads.
Triggers determine when a task runs.
- OnceTrigger: Fires a single time after a delay.
- FixedRateTrigger: Fires at regular intervals (e.g., every 5 minutes). If a task takes too long, subsequent executions may bunch up or be skipped depending on policy.
- FixedDelayTrigger: Fires after a fixed delay after the previous execution completes. Useful for preventing overlap.
- CronTrigger: Fires based on a calendar schedule (e.g., "Mondays at 9 AM").
A task is simply a Runnable. Chronos wraps your runnable to provide:
- History: Tracks run counts, success rates, and last execution times.
-
Safety: Catches exceptions to prevent thread death (configurable via
ExecutionPolicy). - Resilience: Can automatically retry upon failure.
-
State: Tracks lifecycle states (
SCHEDULED,RUNNING,COMPLETED,FAILED,CANCELLED).