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. StartSyncThread();
  13. Thread.sleep(1000);
  14. isRunning = false;
  15. }
  16. private static volatile boolean isRunning = true;
  17. public static void StartSyncThread() {
  18. new Thread() {
  19. public void run() {
  20. long count = 0;
  21. while (isRunning) {
  22. count++;
  23. }
  24. System.out.println("stopped " + count);
  25. }
  26. }.start();
  27. }
  28. }
Success #stdin #stdout 1.12s 320896KB
stdin
Standard input is empty
stdout
stopped 729386640