fn mn_handle() {
        let handle = create_handle(|| {
            for i in 1..10 {
                println!("hi number {} from the spawned thread!", i);
                thread::sleep(Duration::from_millis(1));
            }
        });

        for i in 1..5 {
            println!("hi number {} from the main thread", i);
            thread::sleep(Duration::from_millis(1));
        }

        // calling join on the handle blocks the thread currently running until the thread represented by the handle terminates
        handle.join().unwrap();
    }
// waiting for all threads to finish using join handles
waiting for all threads to finish using join handles
waiting for all threads to finish using join handles
fn mn_handle() {
        let handle = create_handle(|| {
            for i in 1..10 {
                println!("hi number {} from the spawned thread!", i);
                thread::sleep(Duration::from_millis(1));
            }
        });
        for i in 1..5 {
            println!("hi number {} from the main thread", i);
            thread::sleep(Duration::from_millis(1));
        }
        // calling join on the handle blocks the thread currently running until the thread represented by the handle terminates
        handle.join().unwrap();
    }
fn mn_handle ( ) { let handle = create_handle ( | | { for i in 1 .. 10 { println ! ( " " i ) ; thread :: sleep ( Duration :: from_millis ( 1 ) ) ; } } ) ; for i in 1 .. 5 { println ! ( " " i ) ; thread :: sleep ( Duration :: from_millis ( 1 ) ) ; } // calling join on the handle blocks the thread currently running until the thread represented by the handle terminates handle . join ( ) . unwrap ( ) ; }
waiting for all threads to finish using join handles
waiting for all threads to finish using join handles