2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(unused_must_use)]
|
2016-02-11 11:34:41 +00:00
|
|
|
// ignore-emscripten no threads support
|
|
|
|
|
2015-03-27 05:11:50 +00:00
|
|
|
use std::thread;
|
2015-03-06 02:33:58 +00:00
|
|
|
|
2015-03-27 05:11:50 +00:00
|
|
|
fn x(s: String, n: isize) {
|
2014-10-15 01:07:11 +00:00
|
|
|
println!("{}", s);
|
|
|
|
println!("{}", n);
|
2011-10-13 22:37:07 +00:00
|
|
|
}
|
2010-06-24 04:03:09 +00:00
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2015-04-13 22:15:32 +00:00
|
|
|
let t1 = thread::spawn(|| x("hello from first spawned fn".to_string(), 65) );
|
|
|
|
let t2 = thread::spawn(|| x("hello from second spawned fn".to_string(), 66) );
|
|
|
|
let t3 = thread::spawn(|| x("hello from third spawned fn".to_string(), 67) );
|
2015-03-27 05:11:50 +00:00
|
|
|
let mut i = 30;
|
2014-05-13 00:56:43 +00:00
|
|
|
while i > 0 {
|
|
|
|
i = i - 1;
|
|
|
|
println!("parent sleeping");
|
2015-03-27 05:11:50 +00:00
|
|
|
thread::yield_now();
|
2014-05-13 00:56:43 +00:00
|
|
|
}
|
2015-04-13 22:15:32 +00:00
|
|
|
t1.join();
|
|
|
|
t2.join();
|
|
|
|
t3.join();
|
2011-08-19 22:16:48 +00:00
|
|
|
}
|