Q:

Make thread to return value in java

I have web service and web service calls are handled by a Thread, so that they can run asynchronously, and also time out.  But the thread is “runnable” and not “callable” so the thread cannot pass back the web service response.
I have read statement that we need to use a callable.Is their any way to return response from my runnable thread.I am posting small example can we make it to return value.
public class HelloThread extends Thread {

    public void run() {
        System.out.println("Hello from a thread!");
        String a="Hello";
    }

    public static void main(String args[]) {
        (new HelloThread()).start();
    }

}

A:

You should pass a callback to the Thread and the thread can invoke the callback with the value when its done.

