Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 12, 2018 16:01
Show Gist options
  • Save rust-play/07693311cacb61569b678cde5b2d974b to your computer and use it in GitHub Desktop.
Save rust-play/07693311cacb61569b678cde5b2d974b to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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