I am learning to use ExectorService
to pool threads
and send out tasks. I have a simple program below
import java.util.concurrent.Execu
As you see from the JavaDoc execute(Runnable)
does not return anything.
However, submit(Callable
returns a Future
object which allows a way for you to programatically cancel the running thread later as well as get the T
that is returned when the Callable
completes. See JavaDoc of Future for more details
Future> future = executor.submit(longRunningJob);
...
//long running job is taking too long
future.cancel(true);
Moreover,
if future.get() == null
and doesn't throw any exception then Runnable executed successfully