hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Puneet Lakhina" <puneet.lakh...@gmail.com>
Subject Should Multiple threads use same HttpClient object
Date Wed, 17 Oct 2007 09:36:35 GMT
Hi,
My current code using httpclient looks something like this:

public class MyClass {
public void myMethod(String name,String value) {
/*This Method is called repeatedly*/
Thread t = new MyPostThread(name,value);
t.start();
}
public static MyPostThread extends Thread {
String name;
String value;
public MyPostThread(String name,String value) {
this.name=name;
this.value=value;
}
 public void run() {

        HttpClient client = new HttpClient();
        PostMethod postMethod  = new PostMethod(sameURL);
        /*Set parameters in post method*/
        client.executeMethod();
         /*Do something with the response*/
        postMethod.releaseConnection();
}
}

I am a little confused as to how the connection management takes place.
Should i be using the same HttpClient object across different threads?
Should I be in that case using the MultiThreadedConnectionManager?

Any brickkbats, suggestions,comments would be helpful.
-- 
Puneet
http://sahyog.blogspot.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message