Created
July 12, 2018 16:01
-
-
Save rust-play/07693311cacb61569b678cde5b2d974b to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::thread; | |
use std::time::Duration; | |
fn main() { | |
let handle = thread::spawn(|| { | |
for i in 1..10 { | |
println!("hi number {} from the spawned thread!", i); | |
thread::sleep(Duration::from_millis(1)); | |
} | |
}); | |
for i in 1..5 { | |
println!("hi number {} from the main thread!", i); | |
thread::sleep(Duration::from_millis(1)); | |
} | |
handle.join().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment