use std::sync::mpsc; use std::thread; let (tx, rx) = mpsc::channel(); let tx1 = tx.clone(); thread::spawn(move || { tx.send(String::from("来自线程1")).unwrap(); }); thread::spawn(move || { tx1.send(String::from("来自线程2")).unwrap(); }); for received in rx { println!("收到: {}", received); }