use std::thread;
use std::time::Duration;
use std::sync::mpsc;

fn main() {
    let (tx, rx) = mpsc::channel();

    let tx_clone = tx.clone();
    thread::spawn(move || {
        let vals = vec![
            String::from("1000のバイオリン"),
            String::from("24K Magic"),
            String::from("365日の紙飛行機"),
        ];
        for val in vals {
            tx_clone.send(val).unwrap();
            thread::sleep(Duration::from_secs(1));
        }
    }); 

    thread::spawn(move || {
        let vals = vec![
            String::from("6月の雨"),
            String::from("7 Rings"),
            String::from("8 Days a Week"),
        ];
        for val in vals {
            tx.send(val).unwrap();
            thread::sleep(Duration::from_secs(1));
        }
    }); 

    for recv in rx {
        println!("{recv}");
    }
}
