Spawning Threads with std::thread

Updated

October 31, 2026

Spawning Threads with std::thread

Rust guarantees thread safety through its type system.

use std::thread;

fn main() {
    let handle = thread::spawn(|| {
        println!("Worker thread running");
    });

    handle.join().unwrap();
    println!("Worker thread joined");
}