fork download
  1. import java.util.concurrent.Executors;
  2. import java.util.concurrent.ScheduledExecutorService;
  3.  
  4. class Ideone {
  5.  
  6. public static void main(String[] args) throws java.lang.Exception {
  7. ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
  8. final int count = 1;
  9. final int MAX_RETRY = 3;
  10. Runnable runnable = () -> {
  11. try {
  12. //This function can fail and throw FunctionException
  13. // callMyFunction();
  14. } catch (RuntimeException e) {
  15. if (++count <= MAX_RETRY) {
  16. executor.schedule(runnable, 30 * 60 * 1000);
  17. }
  18. }
  19. };
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: cannot assign a value to final variable count
        if (++count <= MAX_RETRY) {
              ^
Main.java:16: error: method schedule in interface ScheduledExecutorService cannot be applied to given types;
          executor.schedule(runnable, 30 * 60 * 1000);
                  ^
  required: Callable<V>,long,TimeUnit
  found: Runnable,int
  reason: cannot infer type-variable(s) V
    (actual and formal argument lists differ in length)
  where V is a type-variable:
    V extends Object declared in method <V>schedule(Callable<V>,long,TimeUnit)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
stdout
Standard output is empty