mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
373 B
17 lines
373 B
use std::thread;
|
|
use std::time::Duration;
|
|
|
|
fn main() {
|
|
thread::spawn(|| {
|
|
for i in 1..10 {
|
|
println!("hi number {i} from the spawned thread!");
|
|
thread::sleep(Duration::from_millis(1));
|
|
}
|
|
});
|
|
|
|
for i in 1..5 {
|
|
println!("hi number {i} from the main thread!");
|
|
thread::sleep(Duration::from_millis(1));
|
|
}
|
|
}
|