fn main() { let mut n = 5; let thread_body = move || { for i in 1..10 { println!("Count {}, n is {}", i, n); std::thread::sleep(std::time::Duration::from_millis(100)); } }; let h = std::thread::spawn(thread_body); std::thread::sleep(std::time::Duration::from_millis(300)); println!("Main thread, here!"); n = 6; println!("My new n value is {}", n); h.join(); }