create thread in rust

179

create thread in rust -

use std::thread;
use std::time::Duration;

fn main() {
    // create a thread
    thread::spawn(|| {
        for i in 0..5 {
            println!("hi number {} from the spawned thread!", i);
        }
    });
}

Comments

Submit
0 Comments