Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. use std::thread;
  2. use std::time::Duration;
  3.  
  4. fn main() {
  5. let hello = "hellow world";
  6. let handle = thread::spawn(move || {
  7. for i in 1..10 {
  8. println!("{}", hello);
  9. println!("hi number {} from the spawned thread!", i);
  10. thread::sleep(Duration::from_millis(1));
  11. }
  12. });
  13. println!("{}", hello);
  14. handle.join().unwrap();
  15.  
  16. for i in 1..5 {
  17. println!("hi number {} from the main thread!", i);
  18. thread::sleep(Duration::from_millis(1));
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement