hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Brown <russel...@basho.com>
Subject Re: Using ThreadSafeClientConnManager
Date Thu, 04 Aug 2011 07:02:25 GMT

On 4 Aug 2011, at 01:18, Mohit Anchlia wrote:

> I am trying to understand these 2:
> 
> ClientConnectionManager cm = new ThreadSafeClientConnManager();
> cm.setMaxTotal(100);
> HttpClient httpClient = new DefaultHttpClient(cm);
> 
> Have couple of questions:
> 
> 1) Can one httpClient object be shared accross multiple threads doing
> post/get/delete/put requests?

Yes.

> 2) What happens in above case if there are more concurrent threads say
> 200 than actual no. of connections? So what happens if 200 threads
> trying to use httpClient object (shared). But we created only 100
> connections. Does it wait on .execute if all connections are busy?

The thread attempting to acquire a connection blocks. If you have set a timeout then it blocks
until the timeout is reached and an exception is thrown.

Worth noting, in your above snippet the max connections per route will only be *2*.

> 
> Can somone please help me understand?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


Mime
View raw message