Skip to content

Instantly share code, notes, and snippets.

@codegod100
Last active March 2, 2023 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codegod100/7480a3d01cd07b14805b05dd378985a5 to your computer and use it in GitHub Desktop.
Save codegod100/7480a3d01cd07b14805b05dd378985a5 to your computer and use it in GitHub Desktop.
#![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