fork download
  1.  
  2. class ThreadEx extends Thread{
  3. @Override
  4. public void run() {
  5. for(;;){
  6. try {
  7. sleep(10);
  8. } catch (InterruptedException e) {
  9. e.printStackTrace();
  10. }
  11. }
  12. }
  13. }
  14.  
  15. public class Main {
  16. public static void main(String[] args) {
  17. final int N=100000;
  18. ThreadEx th[]=new ThreadEx[N];
  19. for(int i=0;i<N;i++){
  20. th[i]=new ThreadEx();
  21. th[i].start();
  22. }
  23. }
  24. }
  25.  
Time limit exceeded #stdin #stdout #stderr 5s 323712KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
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)