struct S { v: i32 } fn main() { let mut n = S{v: 5}; let thread_body = move || { for i in 1..10 { println!("Count {}, n is {}", i, n.v); 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.v = 6; println!("My new n value is {}", n.v); h.join(); }