相关疑难解决方法(0)

在线程之间发送数据的惯用方式是什么?

我想在一个单独的线程中进行一些计算,然后从主线程中恢复数据。在Rust中将一些数据从线程传递到另一个的规范方法是什么?

fn main() {
    let handle = std::thread::spawn(|| {
        // I want to send this to the main thread:
        String::from("Hello world!")
    });

    // How to recover the data from the other thread?

    handle.join().unwrap();
}
Run Code Online (Sandbox Code Playgroud)

multithreading rust

4
推荐指数
1
解决办法
69
查看次数

标签 统计

multithreading ×1

rust ×1