Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 386887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:37:12+00:00 2026-05-12T15:37:12+00:00

I really want to create a subclass of FutureTask that has a default no-arg

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:37:12+00:00Added an answer on May 12, 2026 at 3:37 pm

    You could do this using composition and the creation of an abstract class. now you clients are decoupled from the callable interface.

    import java.util.concurrent.Callable;
    import java.util.concurrent.FutureTask;
    
    public abstract class MyFutureClass<V> implements Callable<V> {
    
    private final FutureTask<V> futureTask;
    
    public MyFutureClass() {
        futureTask = new FutureTask<V>(this);
    }
    
    @Override
    public V call() throws Exception {
        return myCall();
    }
    
    protected abstract V myCall();
    
    public FutureTask<V> getFutureTask() {
        return futureTask;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really want to create a stunning-looking GUI desktop application that looks like, for
I want to create a constructor function in javascript, which has a .prototype property
Is there a way to dynamically create a selectItem list? I dont really want
I want to create a report, using either Crystal reports or RDLC, doesn't really
I am really confused. I want to create a Select drop down menu using
okay...im really puzzled with this. I want to create a regular asp.net webforms website
I want to create a subclass of UINavigationController which always starts with the same
I want to create my own control that will consist of several UILabels and
What I really want is a class with a generic constructor, and when a
I want to create a calendar in my application that external users can view.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.