threads/
threads.rs

1extern crate waitout;
2
3use waitout::WaitGroup;
4use std::sync::Arc;
5use std::thread;
6
7fn main() {
8    let wg = Arc::new(WaitGroup::new(0));
9    for _ in 0..100 {
10        wg.add(1);
11        let wg2 = wg.clone();
12        thread::spawn(move || {
13            thread::sleep_ms(2000);
14            wg2.done();
15        });
16    }
17    wg.wait();
18    println!("done")
19}