Created
August 30, 2018 16:57
-
-
Save YassineBajdou/2f045e28854238538155f404171cad3a to your computer and use it in GitHub Desktop.
This file contains 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::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