expression
Configure the blocking pool limit
Limit blocking threads separately from async workers. Excess blocking jobs may queue, so this setting is not sufficient admission control. Join finite work before dropping the runtime. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 25 Common mistake: Treating max_blocking_threads as a bounded task queue or a per-request timeout.
Formal Syntax & Structure
rust syntaxrust
Builder::max_blocking_threads(n)Working Example
Example Snippetrust
fn main() { let rt = tokio::runtime::Builder::new_current_thread().max_blocking_threads(2).build().unwrap(); let n = rt.block_on(async { tokio::task::spawn_blocking(|| 5u32 * 5).await.unwrap() }); println!("{n}");}