mirror of https://github.com/rust-lang/book
17 lines
373 B
Rust
17 lines
373 B
Rust
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));
|
|
}
|
|
}
|