Skip to content

Instantly share code, notes, and snippets.

@thehydroimpulse
Last active August 29, 2015 14:01
Show Gist options
  • Save thehydroimpulse/f6c25c30fc29e1cc389f to your computer and use it in GitHub Desktop.
Save thehydroimpulse/f6c25c30fc29e1cc389f to your computer and use it in GitHub Desktop.
extern crate sync;
use sync::Arc;
fn main() {
let numbers = ~[1,2,3];
let numbers = Arc::new(numbers);
for num in range(0, 3) {
let (tx, rx) = channel();
tx.send(numbers.clone());
spawn(proc() {
let numbers = rx.recv();
println!("{:d}", numbers[num as uint]);
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment