hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ossf...@dubioso.net>
Subject Re: Should Multiple threads use same HttpClient object
Date Thu, 18 Oct 2007 14:35:25 GMT
Puneet Lakhina wrote:
>  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();
> }

This will leak a connection for every request, until they
are released by garbage collection.

> 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?

Yes and yes. You are looking for the Threading Guide:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/threading.html

hope that helps,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message