Moving Values into Threads
Exercises
Moving
Solution
use std::thread;
fn main() {
let msg = "Hello from spawned thread".to_owned();
let handle = thread::spawn(move || {
println!("{msg}");
});
handle.join().unwrap();
}
use std::thread;
fn main() {
let msg = "Hello from spawned thread".to_owned();
let handle = thread::spawn(move || {
println!("{msg}");
});
handle.join().unwrap();
}