thread-group 1.0.0

std::thread::ThreadGroup prototype
use std::thread;
use std::time::Duration;

fn main() {
    let mut threads = vec![];
    for i in 0..5 {
        let handle = thread::spawn(move || match i {
            4 => panic!("oh no!"),
            _ => thread::sleep(Duration::from_secs(1)),
        });
        threads.push(handle);
    }

    for (i, handle) in threads.into_iter().enumerate() {
        println!("joining thread #{}", i);
        handle
            .join()
            .unwrap_or_else(|_| panic!("thread #{} panicked", i));
    }
}