You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
486 B
Rust

use std::{thread,time};
use std::process;
extern crate thread_id;
fn main() {
for _ in 0..3 {
thread::spawn(|| {
let t = time::Duration::from_millis(1000);
loop {
println!("child thread #{}:{}", process::id(), thread_id::get());
thread::sleep(t);
}
});
}
let t = time::Duration::from_millis(1000);
loop {
println!("parent thread #{}:{}", process::id(), thread_id::get());
thread::sleep(t);
}
}