Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 6, 2019 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/55a6f21f5ce018ce82756d783517c458 to your computer and use it in GitHub Desktop.
Save rust-play/55a6f21f5ce018ce82756d783517c458 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
use std::sync::Arc;
use std::thread;
fn main() {
let five: Arc<i32> = Arc::new(5);
for _ in 0..10 {
let five: Arc<i32> = Arc::clone(&five);
thread::spawn(move || {
println!("{:#?}", five);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment