fork download
  1. class TestSleepMethod1 extends Thread{
  2. public void run(){
  3. for(int i=1;i<5;i++){
  4. try{Thread.sleep(500);}catch(InterruptedException e){System.out.println(e);}
  5. System.out.println(i);
  6. }
  7. }
  8. public static void main(String args[])throws Exception{
  9. TestSleepMethod1 t1=new TestSleepMethod1();
  10. TestSleepMethod1 t2=new TestSleepMethod1();
  11.  
  12. t1.start();
  13. t2.start();
  14. }
  15. }
Runtime error #stdin #stdout #stderr 0.04s 4452352KB
stdin
Standard input is empty
stdout
1
2
3
4
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 TestSleepMethod1.main(Main.java:13)