其他分享
首页 > 其他分享> > Rust中的并发

Rust中的并发

作者:互联网

std::thread

use std::{thread::{self, JoinHandle, sleep}, time::Duration};

fn main() -> std::io::Result<()> {
    let jh: JoinHandle<i32> = thread::spawn(|| {
        sleep(Duration::from_millis(3000));
        88
    });
    let a: i32 = jh.join().unwrap();
    println!("Hello, world! {}", a);
    Ok(())
}

END

标签:std,thread,JoinHandle,并发,jh,Duration,sleep,Rust
来源: https://www.cnblogs.com/develon/p/14716656.html