hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Terrell" <Steve.Terr...@guideworkstv.com>
Subject RE: Is this a good idea?
Date Fri, 09 Feb 2007 13:12:07 GMT
Well, that's the thing. The HttpState will be wrapped up in the
singleton. Some of the servers we support will allow up to 32
simultaneous threads of execution. How will that work when all posts are
done via a singleton?


-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Sent: Friday, February 09, 2007 1:14 AM
To: HttpClient User Discussion
Subject: Re: Is this a good idea?

Hello Steve,

>    I think I am losing an argument at work. A coworker is implementing
> some code that will be used to call a servlet. HttpClient is the tool
> choice, of course. The code he is writing must handle multiple
> in parallel, thus he will be using the MultiThreadedConnectionManager.
> However, he is proposing to channel all his requests through a
> singleton. 

This is exactly how HttpClient is supposed to be used. Each thread
that calls the singleton HttpClient will get it's own connection from
the MTHCM (assuming the connection limits are chosen appropriately).
MTHCM is internally synchronized.
You only have to take care about HttpState. HttpClient holds a single
default HttpState, which is also synchronized internally. If it's OK
for all the threads to share one state, that's fine. Otherwise, each
thread has to keep it's own HttpState and pass it to execute().

hope that helps,

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

View raw message