java-executors
Installation
SKILL.md
Java Executors for Android
Instructions
java.util.concurrent is the foundation of every non-UI thread on Android. Build on it directly — avoid Thread.start(), AsyncTask, and Handler(new HandlerThread(...)) unless you are integrating with legacy APIs.
1. Pool Types
| Call | Use when |
|---|---|
Executors.newSingleThreadExecutor() |
Sequential work, e.g. per-feature repository. |
Executors.newFixedThreadPool(n) |
Parallel CPU-bound work. n = Runtime.availableProcessors(). |
Executors.newCachedThreadPool() |
Short bursts of IO-bound work. Dangerous unbounded; avoid. |
Custom ThreadPoolExecutor |
Anything shipped to production. See below. |
Executors.newScheduledThreadPool(1) |
Periodic or delayed tasks (prefer WorkManager for > 15 min). |