From Chocolate Penguin, 9 Years ago, written in Plain Text.
Embed
  1. this is thread number 32741
  2. this is thread number 32742
  3. this is thread number 32743
  4. this is thread number 32744
  5. this is thread number 32745
  6. this is thread number 32746
  7. thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 11, message: "Resource temporarily unavailable" } }', src/libcore/result.rs:746
  8. note: Run with `RUST_BACKTRACE=1` for a backtrace.
  9.  
  10.  
  11.  
  12. code:
  13.  
  14. use std::thread;
  15.  
  16. static NTHREADS: i32 = 100000;
  17.  
  18. // This is the `main` thread
  19. fn main() {
  20.     // Make a vector to hold the children which are spawned.
  21.     let mut children = vec![];
  22.  
  23.     for i in 0..NTHREADS {
  24.         // Spin up another thread
  25.         children.push(thread::spawn(move || {
  26.             println!("this is thread number {}", i)
  27.         }));
  28.     }
  29.  
  30.     for child in children {
  31.         // Wait for the thread to finish. Returns a result.
  32.         let _ = child.join();
  33.     }
  34. }
  35.  
  36. Rust: DISQUALIFIED.

Replies to Rust's threads are non-lightweight rss

Title Name Language When
*Hint hint*: Golang can handle it :p Bulky Stork text 9 Years ago.