class ThreadEx extends Thread{ @Override public void run() { for(;;){ try { sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } }} public class Main { public static void main(String[] args) { final int N=100000; ThreadEx th[]=new ThreadEx[N]; for(int i=0;i<N;i++){ th[i]=new ThreadEx(); th[i].start(); } }}
Standard input is empty
Standard output is empty
Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at Main.main(Main.java:21)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!