2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(unused_must_use)]
|
2024-03-06 12:19:20 -08:00
|
|
|
//@ needs-threads
|
2016-02-11 12:34:41 +01:00
|
|
|
|
2015-03-26 22:11:50 -07:00
|
|
|
use std::thread;
|
2015-03-05 18:33:58 -08:00
|
|
|
|
2015-03-26 22:11:50 -07:00
|
|
|
fn x(s: String, n: isize) {
|
2014-10-14 21:07:11 -04:00
|
|
|
println!("{}", s);
|
|
|
|
println!("{}", n);
|
2011-10-13 15:37:07 -07:00
|
|
|
}
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2024-08-24 05:32:52 +02: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-26 22:11:50 -07:00
|
|
|
let mut i = 30;
|
2014-05-12 17:56:43 -07:00
|
|
|
while i > 0 {
|
|
|
|
i = i - 1;
|
|
|
|
println!("parent sleeping");
|
2015-03-26 22:11:50 -07:00
|
|
|
thread::yield_now();
|
2014-05-12 17:56:43 -07:00
|
|
|
}
|
2015-04-13 15:15:32 -07:00
|
|
|
t1.join();
|
|
|
|
t2.join();
|
|
|
|
t3.join();
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|