Zest.

Rust: Spawn a thread

A short, tested Rust example for spawn a thread. Copy it and adjust the names and paths for your project.

Rust
use std::thread;

let handle = thread::spawn(|| {
    println!("in a thread");
    42
});
let result = handle.join().unwrap();

Find it in Zest

Search for “rust spawn a thread” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Rust examples

All Rust examples