fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.concurrent.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. // Do-nothing Callable
  12. static class FactorialCalculator implements Callable {
  13. private final String name;
  14. public FactorialCalculator(String name) {
  15. this.name = name;
  16. }
  17.  
  18. public Object call() {
  19. return null;
  20. }
  21. }
  22.  
  23. public static void main (String[] args) throws java.lang.Exception
  24. {
  25. final ExecutorService threadpool = Executors.newFixedThreadPool(20);
  26. FactorialCalculator task1 = new FactorialCalculator("A");
  27. FactorialCalculator task2 = new FactorialCalculator("B");
  28. FactorialCalculator task3= new FactorialCalculator("C");
  29. FactorialCalculator task4 = new FactorialCalculator("D");
  30. FactorialCalculator task5= new FactorialCalculator("E");
  31. System.out.println("Submitting Task ...");
  32. Future future1 = threadpool.submit(task1);
  33. Future future2 = threadpool.submit(task2);
  34. Future future3 = threadpool.submit(task3);
  35. Future future4 = threadpool.submit(task4);
  36. Future future5 = threadpool.submit(task5);
  37. System.out.println("Task is submitted");
  38. }
  39. }
Time limit exceeded #stdin #stdout 5s 322176KB
stdin
Standard input is empty
stdout
Submitting Task ...
Task is submitted