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

  • Home
  • SEARCH
  • 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 8932549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:20:19+00:00 2026-06-15T09:20:19+00:00

The run method of Runnable has return type void and cannot return a value.

  • 0

The run method of Runnable has return type void and cannot return a value. I wonder however if there is any workaround of this.

I have a method like this:

public class Endpoint {
    public method() {
       Runnable runcls = new RunnableClass();
       runcls.run()
    }
}

The method run is like this:

public class RunnableClass implements Runnable {
    
    public JaxbResponse response;

    public void run() {
        int id = inputProxy.input(chain);
        response = outputProxy.input();
    }
}

I want to have access to response variable in method. Is this possible?

  • 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-06-15T09:20:20+00:00Added an answer on June 15, 2026 at 9:20 am

    Use Callable<V> instead of using Runnable interface.

    Example:

    public static void main(String args[]) throws Exception {
        ExecutorService pool = Executors.newFixedThreadPool(3);
        Set<Future<Integer>> set = new HashSet<>();
    
        for (String word : args) {
          Callable<Integer> callable = new WordLengthCallable(word);
          Future<Integer> future = pool.submit(callable);
          set.add(future);
        }
    
        int sum = 0;
        for (Future<Integer> future : set) {
          sum += future.get();
        }
    
        System.out.printf("The sum of lengths is %s%n", sum);
        System.exit(sum);
    }
    

    In this example, you will also need to implement the class WordLengthCallable, which implements the Callable interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread with this run method: public void run(){ MAPTable t1 =
So I've got a Java class that implements Runnable. In the run method I've
Initialising the Foo object does run the method func(), but the value of self.a
My code looks like this, this is Server code ( Runnable ) public void
I am trying to pop up dialog from run method it gives me exception
I need to run some method in Swing application in separate thread. What is
How can we run a method before running each Action in MVC3? I know
I realize that the method run() must be declared because its declared in the
I have a unit test where I run a method for every item in
I'm trying to use a timer in C# to run a method at an

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.