fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.concurrent.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. System.out.println("Before");
  10. ExecutorService executorService = Executors.newFixedThreadPool(1);
  11. FutureTask<Object> futureTask = new FutureTask<Object>(new Runnable() {
  12. public void run()
  13. {
  14. System.out.println("Hello async world!");
  15. try
  16. {
  17. Thread.sleep(1000);
  18. }
  19. catch (InterruptedException interruptedException)
  20. {
  21. System.out.println("Err: " + interruptedException);
  22. }
  23. System.out.println("I'm finally done");
  24. }
  25. }, null);
  26. System.out.println("Defined");
  27. System.out.println(new Date());
  28. executorService.execute(futureTask);
  29. System.out.println("Running");
  30. System.out.println(new Date());
  31. while (!futureTask.isDone())
  32. {
  33. System.out.println("Task not yet completed.");
  34.  
  35. try
  36. {
  37. Thread.sleep(300);
  38. }
  39. catch (InterruptedException interruptedException)
  40. {
  41. }
  42. }
  43. System.out.println("Done");
  44. System.out.println(new Date());
  45. }
  46. }
Time limit exceeded #stdin #stdout 5s 381312KB
stdin
Standard input is empty
stdout
Before
Defined
Mon Jun 03 20:11:50 GMT 2013
Running
Mon Jun 03 20:11:50 GMT 2013
Task not yet completed.
Hello async world!
Task not yet completed.
Task not yet completed.
Task not yet completed.
I'm finally done
Done
Mon Jun 03 20:11:51 GMT 2013