use std::thread;

fn main() {
    let mut counter = 0;
    const NUM: usize = 500_000;
    let mut handles = vec![];
    for _i in 0..NUM {
        handles.push(thread::spawn(move || {
            counter += 1;
        }));
    }
    for handle in handles {
        handle.join().unwrap();
    }
    println!("counter: {}", counter);
}