我想在一个单独的线程中进行一些计算,然后从主线程中恢复数据。在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)