hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bindul Bhowmik" <bindulbhow...@gmail.com>
Subject Re: Is this a good idea?
Date Thu, 08 Feb 2007 21:33:14 GMT

On 2/8/07, Steve Terrell <Steve.Terrell@guideworkstv.com> wrote:
> Folks,
>    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 of
> choice, of course. The code he is writing must handle multiple requests
> in parallel, thus he will be using the MultiThreadedConnectionManager.
> However, he is proposing to channel all his requests through a
> singleton.
>    I just don't see how that will work. I am convinced the singleton
> will have the effect of serializing the requests, since each request
> will only get processed when the singleton gets a time slice from the
> jvm. Am I nuts for thinking the singleton will be a bottleneck?

I am afraid that is not exactly true. If multiple threads are sending
in the requests, the method(s) in the singleton that executes the
request will run in all those threads in parallel. The singleton
however will have to take on the additional overhead of synchronizing
access to any fields in the singleton that get modified during the
request execution, and also for state management (if any).

Regarding the executing in a time slice from the JVM, any
multi-threaded application on a single CPU machine works only on time
slices of the CPU. I don't see how a singleton makes a difference

> --Steve


Bindul Bhowmik
MindTree Consulting Ltd.

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

View raw message