diff options
Diffstat (limited to 'src/doc/book/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs')
-rw-r--r-- | src/doc/book/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs b/src/doc/book/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs new file mode 100644 index 000000000..fbba9167d --- /dev/null +++ b/src/doc/book/listings/ch16-fearless-concurrency/listing-16-08/src/main.rs @@ -0,0 +1,14 @@ +use std::sync::mpsc; +use std::thread; + +fn main() { + let (tx, rx) = mpsc::channel(); + + thread::spawn(move || { + let val = String::from("hi"); + tx.send(val).unwrap(); + }); + + let received = rx.recv().unwrap(); + println!("Got: {}", received); +} |