Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::thread;
- use std::time::Duration;
- fn main() {
- let hello = "hellow world";
- let handle = thread::spawn(move || {
- for i in 1..10 {
- println!("{}", hello);
- println!("hi number {} from the spawned thread!", i);
- thread::sleep(Duration::from_millis(1));
- }
- });
- println!("{}", hello);
- handle.join().unwrap();
- for i in 1..5 {
- println!("hi number {} from the main thread!", i);
- thread::sleep(Duration::from_millis(1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement