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

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

    thread::spawn(move || {
        thread::sleep(Duration::from_secs(1));
        let val = String::from("こんにちは！");
        tx.send(val).unwrap();
    });

    // let received = rx.recv().unwrap();
    // println!("{received}");

    loop {
        if let Ok(received) = rx.try_recv() {
            println!("{received}");
            break;
        }
        print!(".");
        thread::sleep(Duration::from_millis(100));
    }
}
 