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

fn main() {
    let count = Arc::new(Mutex::new(0_usize));

    let h1 = {
        let count = count.clone();
        thread::spawn(move || {
            let mut c = count.lock().unwrap();
            *c += 1;
            println!("Thread #1: {}", c);
        })
    };
    let h2 = {
        let count = count.clone();
        thread::spawn(move || {
            let mut c = count.lock().unwrap();
            *c += 1;
            println!("Thread #2: {}", c);
        })
    };

    h1.join().unwrap();
    h2.join().unwrap();
}