-
Notifications
You must be signed in to change notification settings - Fork 0
Threading Model
frosxt edited this page Jan 20, 2026
·
1 revision
Chronos was designed with a simple but high-performance threading model. Understanding this model is key to configuring your scheduler correctly.
Chronos uses a fixed-size pool of Platform Threads.
-
Configuration: Set via
SchedulerSpec.builder().threadCount(N). - Behavior: All tasks (One-Shot, Fixed-Rate, Cron) share this same pool.
-
Isolation: Chronos isolates its internal loop from user tasks. The scheduler thread manages triggers, while the worker pool executes the user's
Runnable.
Scheduler scheduler = Chronos.create(SchedulerSpec.builder()
.threadCount(4) // 4 concurrent tasks allowed
.build());Since the pool size is fixed, long-running blocking operations (e.g., synchronous HTTP calls with long timeouts, DB queries) can exhaust the worker threads.
- Good: Short, CPU-bound tasks or non-blocking I/O.
-
Mitigation: If you must block, increase
threadCountto accommodate the wait times, or offload the blocking work to a separate, dedicatedExecutorService.
Chronos names threads using the prefix defined in configuration. This helps significantly with debugging and log analysis.
-
Default:
chronos-worker-N - Custom:
.threadNamePrefix("payment-processor-")
// Threads will be: payment-processor-1, payment-processor-2, etc.Chronos uses Platform Threads to ensure maximum compatibility with the broadest range of execution environments.