I really want to create a subclass of FutureTask that has a default no-arg constructor. In particular, I want my subclass to implement the Callable interface and use itself as the callable. This way, users of MyFutureTask can just subclass MyFutureTask instead of having to implement their own callable and pass it to an instance of FutureTask.
Here's the general idea:
public abstract class MyFutureTask<Result> extends FutureTask<Result> implements Callable<Result> {
public MyFutureTask() {
super( /*XXX*/ );
}
public abstract Result call() throws Exception;
}
The problem is, what can I put in the XXX
? FutureTask requires a Callable, but I can't pass this
because java doesn't allow references to this
from within a call to super
. I can't instantiate a nested class since that's also disallowed.
Is there a clever (or non-clever) way I can do this?