# Spring Boot Scheduling

> Standards for scheduled tasks and distributed locking with ShedLock

- Skill: `fierzone/spring-boot-scheduling` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add fierzone/spring-boot-scheduling`
- Raw SKILL.md: https://api.skillmd.com/api/skills/fierzone/spring-boot-scheduling/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: fierzone (https://skillmd.com/u/fierzone)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/fierzone/spring-boot-scheduling

---


# Spring Boot Scheduling Standards

## **Priority: P0**

## Implementation Guidelines

### Scheduled Tasks

- **ThreadPool**: ALWAYS configure a dedicated `TaskScheduler` (default is 1 thread).
- **Async**: Keep `@Scheduled` methods light; offload to `@Async`/Queues.

### Distributed Locking (ShedLock)

- **Problem**: `@Scheduled` runs on ALL pods in K8s.
- **Solution**: Use **ShedLock** to guarantee single execution.
- **Config**: Set `lockAtMostFor` (deadlock safety) and `lockAtLeastFor` (debounce).

## Anti-Patterns

- **Default Pool**: `**No Default Pool**: Configure ThreadPool.`
- **No Locking**: `**No duplicates**: Use Distributed Lock.`
- **Stateful Tasks**: `**No State**: Assume pod restarts.`

## References

- [Implementation Examples](references/implementation.md)

