fork(1) 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. static int x = 0;
  10. static volatile int y = 0;
  11.  
  12. private static void count() {
  13. for (int q=0; q<100000000; ++q) {
  14. ++x;
  15. ++y;
  16. }
  17. }
  18.  
  19. public static void main (String[] args) throws java.lang.Exception {
  20. Thread t[] = new Thread[2];
  21.  
  22. for (int q=0; q<t.length; ++q) {
  23. (t[q] = new Thread(Ideone::count)).start();
  24. }
  25.  
  26. for (int q=0; q<t.length; ++q) {
  27. t[q].join();
  28. }
  29.  
  30. System.out.println(x + " " + y);
  31. }
  32. }
Success #stdin #stdout 1.58s 711168KB
stdin
Standard input is empty
stdout
199811097 200000000