std-module
std::thread: native threads
A native thread is an independently scheduled execution path within a process. Threads can share address space, but access to mutable shared state must respect Rust synchronization rules. This example collects work before exiting. Expected stdout (not executed): 42 Common mistake: Assuming the main function waits for every detached thread.
Formal Syntax & Structure
rust syntaxrust
use std::thread;Working Example
Example Snippetrust
fn main() { let worker = std::thread::spawn(|| 6 * 7); println!("{}", worker.join().unwrap());}