I have a Java class that extends Thread
, it basically looks like the following:
public class HttpRequestDispatcher extends Thread {
private String url;
private String method; // GET or POST
private byte[] postData;
public HttpRequestDispatcher(String url, String method, byte[] postData) {
this.url = url;
this.method = method;
this.postData = postData;
}
public HttpRequestDispatcher(String url, String method) {
this.url = url;
this.method = method;
}
public void run() {
...
}
}
I need the run()
method to return a ByteArrayOutputStream
or a String
. However, because it is in the run()
method of the Thread
, I cannot set the return type of the method to a ByteArrayOutputStream
or a String
.
The HttpRequestDispatcher
class is called inside of a class called OAuth.java.
How can I get around this situation?