Mercurial > hg > Members > kono > rust-tutorial
view src/t16thread/src/main.rs @ 12:70ab6c2f7f6e
fu_test worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 18 Jan 2021 20:52:32 +0900 |
parents | 7eb649571bc6 |
children |
line wrap: on
line source
use t16thread::mpsc_test::mainc; use t16thread::mpsc_test::mainm; use t16thread::racecondition::mainr; use std::thread; use std::time::Duration; fn main1() { let v = vec![1, 2, 3]; let handle = thread::spawn(move || { println!("Here's a vector: {:?}", v); }); // drop(v); handle.join().unwrap(); } fn main() { let handle = thread::spawn(|| { for i in 0..10 { println!("hi number {} from the spawned thread!", i); thread::sleep(Duration::from_millis(1)); } }); for i in 1..5 { println!("hi number {} from the main thread!", i); thread::sleep(Duration::from_millis(1)); } handle.join().unwrap(); // without this, some data are dropped main1(); mainm(); mainc(); mainr(); t16thread::racecondition::mainu(); }