fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Thread one = new Thread(Ideone::foo);
  13. Thread two = new Thread(() -> bar(0));
  14.  
  15. one.start();
  16. two.start();
  17.  
  18. System.out.println("main, foo and bar now execute concurrently...");
  19.  
  20. one.join();
  21. two.join();
  22.  
  23. System.out.println("foo and bar completed.");
  24. }
  25.  
  26. static void foo() {
  27.  
  28. }
  29.  
  30. static void bar(int x) {
  31.  
  32. }
  33. }
Runtime error #stdin #stdout #stderr 0.14s 4452352KB
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 Ideone.main(Main.java:16)