Warning
This post was published 50 days ago. The information described in this article may have changed.
I don't understand why rust compiler would have a problem with Listing 16-3 in the rustbook: Using Threads to Run Code Simultaneously - The Rust Programming Language
Pasting that code snippet below for convenience:
use std::thread;
fn main() {
let v = vec![1, 2, 3];
let handle = thread::spawn(|| {
println!("Here's a vector: {v:?}");
});
handle.join().unwrap();
}
The main thread won't exit without the spawned thread being joined anyway. Even if the OS schedules that thread for later, the main thread is still blocked on the call to join.
Any ideas?
11 posts - 6 participants
🏷️ rust_feed