Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::thread;
- use std::sync::mpsc::channel;
- fn main() {
- let (tx, rx) = channel();
- for i in 0..10 {
- let tx = tx.clone();
- thread::spawn(move|| {
- tx.send(i).unwrap();
- });
- }
- for _ in 0..10 {
- let j = rx.recv().unwrap();
- assert!(0 <= j && j < 10);
- }
- }
Add Comment
Please, Sign In to add comment