fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.time.*;
  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 mai2n (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14.  
  15. public static void main(String[] args) {
  16. TT jump = new TT(() -> {
  17. while (true) {
  18. if (TT.flag) {
  19. System.out.println("jump");
  20. break;
  21. }
  22. }
  23. });
  24. jump.start();
  25. new TT(() -> {
  26. TT.flag = true; // P1
  27. LocalDateTime t1 = LocalDateTime.now();
  28. while (true) {
  29. if (Duration.between(t1, LocalDateTime.now()).toMillis() > 100) {
  30. break;
  31. }
  32. }
  33. System.out.println("flag");
  34. }).start();
  35.  
  36. }
  37.  
  38. static class TT extends Thread {
  39. public static boolean flag = false;
  40. public TT(Runnable o) {
  41. super(o);
  42. }
  43. }
  44. }
Time limit exceeded #stdin #stdout 5s 38904KB
stdin
Standard input is empty
stdout
flag