fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main implements Runnable
  6. {
  7. static Thread thread;
  8.  
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. Main.thread = new Thread(new Main("Hoge", 200));
  12. Main.thread.start();
  13. Main.thread = new Thread(new Main("Unko", 500));
  14. Main.thread.start();
  15. Main.thread = null;
  16. System.exit(0);
  17. }
  18.  
  19. String mes;
  20. long wait;
  21.  
  22. Main(String mes, long wait) {
  23. this.mes = mes;
  24. this.wait = wait;
  25. }
  26.  
  27. @Override
  28. public void run() {
  29. for (int i = 0; i < 5; ++i) {
  30. long t = System.currentTimeMillis(), d;
  31. System.out.println(mes);
  32. do {
  33. d = System.currentTimeMillis();
  34. } while (d - t < wait);
  35. }
  36. }
  37. }
Success #stdin #stdout 0.08s 380864KB
stdin
Standard input is empty
stdout
Hoge
Unko