Work-Stealing Scheduler
Each worker thread has a local task queue. When empty, it steals from another thread's queue.
Benefits:
- No global lock on the task queue
- Cache locality: tasks run on the same thread they were spawned (usually)
- Load balancing: busy threads donate work to idle ones
Tokio's multi-thread runtime uses num_cpus worker threads by default.
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_all()
.build()?;