Last active
March 2, 2023 20:52
-
-
Save codegod100/7480a3d01cd07b14805b05dd378985a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
use std::{process, thread}; | |
fn main() { | |
let mut threads = vec![]; | |
let str = std::fs::read_to_string("/proc/sys/kernel/threads-max").unwrap(); | |
let maxt: i32 = str.trim().parse().unwrap(); | |
let mut count = 0; | |
for x in 1..maxt { | |
let b = thread::Builder::new(); | |
let r = b.spawn(move || { | |
println!("YOLO IM IN THREAD#{}", x); | |
}); | |
let t = match r { | |
Ok(t) => t, | |
Err(err) => { | |
println!("{} we made it to {}", err, count); | |
process::exit(1); | |
} | |
}; | |
threads.push(t); | |
count += 1; | |
} | |
for thread in threads { | |
thread.join().unwrap(); | |
} | |
println!("WE MADE IT!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment