I have a singleThreadExecutor in order to execute the tasks I submit to it in serial order i.e. one task after another, no parallel execution.
I have runnable which
If you wanted to be really thorough, FutureTask
keeps track of states READY
, RUNNING
, RAN
, and CANCELLED
internally. You could create a copy of this class and add an accessor for the state. Then override AbstractExecutorService.newTaskFor(Runnable)
to wrap it using your CustomFutureTask
(the inner class is private
, so just subclassing won't work).
The default implementation of newTaskFor(Runnable)
is really simple:
protected RunnableFuture newTaskFor(Runnable runnable, T value) {
return new FutureTask(runnable, value);
}
so it wouldn't be a big deal to override it.