Simple thread
- In this case when the main thread does not do “extra job” it is obvious that the other thread did not even have a chance to start working.
use std::thread;
fn main() {
println!("Before starting: {:?}", thread::current().id());
thread::spawn(|| {
println!("In thread {:?}", thread::current().id());
});
println!("After ending: {:?}", thread::current().id());
}
Before starting: ThreadId(1)
After ending: ThreadId(1)
- thread
- spawn