fn main() {
let counter = Arc::new(Mutex::new(0));
let mut handles = vec![];
for _ in 0..10 {
let counter = counter.clone();
let handle = thread::spawn(move || {
let mut num = counter.lock().unwrap();
*num += 1;
});
handles.push(handle);
}
//...
}
[1] https://doc.rust-lang.org/book/second-edition/ch16-03-shared...
I don't think he addresses this subject in the book or in his talks, but it would be interesting to know his opinion on the subject.