Seeking Clarity on Java ScheduledExecutorService and FutureTask Seeking Clarity on Java ScheduledExecutorService and FutureTask multithreading multithreading

Seeking Clarity on Java ScheduledExecutorService and FutureTask


The problem is that FutureTask is used, and as its class documentation says, "Once the computation has completed, the computation cannot be restarted or cancelled."

After the run method of FutureTask has been invoked once, subsequent invocations return immediately, without delegating to the task's Callable instance.

Only a Runnable can be used as a recurring task, and this doesn't allow passing back a result. Instead, give the Runnable task a callback that it can invoke at the end of its run method, to report the results of each execution of the task back to listeners in other threads.