std-type

JoinHandle: owned permission to wait

A join handle represents the right to wait for a worker and retrieve its result. Joining consumes the handle; dropping it detaches the thread rather than cancelling it. Expected stdout (not executed): report Common mistake: Trying to clone or join the same handle twice.

Formal Syntax & Structure

rust syntaxrust
JoinHandle<T>

Working Example

Example Snippetrust
fn main() {    let handle: std::thread::JoinHandle<String> = std::thread::spawn(|| String::from("report"));    let text = handle.join().unwrap();    println!("{text}");}
Rust Reference