use std::thread;
use std::sync::{Arc, Mutex};

fn main() {
    let list = Arc::new(Mutex::new(Vec::new()));
    let mut handles = vec![];
    for i in 1..=10 {
        let list_clone = Arc::clone(&list);
        let handle = thread::spawn(move || {
            let mut num = list_clone.lock().unwrap();
            num.push(i);
        });
        handles.push(handle);
    }
    for handle in handles {
        handle.join().unwrap();
    }
    println!("list: {:?}", *list.lock().unwrap());
}