An async server can spawn a task for each incoming HTTP request. The async runtime schedules those tasks for execution, allowing the server to handle multiple requests concurrently. A task is not the same as an operating-system thread: the runtime manages task scheduling, while the operating system schedules threads. section 10.1 section 10.6
Run two file reads
In src/main.rs, mark main with #[tokio::main] and async. Spawn each simulated file read with tokio::spawn(async { ... }), call its async function with .await inside the spawned block, then wait for both handles with tokio::join!(h1, h2). Without .await, the async file-read functions do not execute. The example uses Tokio 1 with its full feature set in Cargo.toml. section 10.2
A spawned task may contain one or more futures. When a future is polled, Poll::Ready supplies its value; Poll::Pending means it is not ready. A waker can notify the executor to poll the associated task again. In a custom timer example, the pending timer arranges a later wake-up, letting the runtime schedule another task in the meantime. A synchronous sleep inside an async function, by contrast, pauses the current thread. section 10.4 section 10.5
Shows how the Tokio executor, a spawned task, and its future relate. section 10.4









