Skip to content

Instantly share code, notes, and snippets.

@YassineBajdou
Created August 30, 2018 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YassineBajdou/2f045e28854238538155f404171cad3a to your computer and use it in GitHub Desktop.
Save YassineBajdou/2f045e28854238538155f404171cad3a to your computer and use it in GitHub Desktop.
use std::thread;
use std::sync::mpsc;
fn main() {
let (tx, rx) = mpsc::channel();
for _ in 0..10 {
let tx = tx.clone();
thread::spawn(move || {
let result = 77u32;
tx.send(result);
});
}
rx.recv().ok().expect("could not receive the result.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment