MPSC

Multi-producer, single consumer FIFO queue

チャンネルを使ったメッセージングをするためのモデル.
Rust だと std::sync::mpsc を使う

use std::thread;
use std::sync::mpsc;
 
fn main() {
		// tx: 転送機
		// rx: 受信機
    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);
}