Skip to content

Instantly share code, notes, and snippets.

@pfirpfel
Created February 21, 2013 13:27
Show Gist options
  • Save pfirpfel/5004720 to your computer and use it in GitHub Desktop.
Save pfirpfel/5004720 to your computer and use it in GitHub Desktop.
public class MaxThreads {
private static int count = 0;
public static void main (String[] args){
while(true){
Thread t = new Thread(new T(), ++count + "");
t.start();
System.out.println(count + "");
}
}
}
class T implements Runnable {
@Override
public void run() {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
System.err.println(e.getMessage());
}
}
}
@pfirpfel
Copy link
Author

My PC stopped add around 120k threads AND I managed to recover my system ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment