Steve, On 2/8/07, Steve Terrell <[EMAIL PROTECTED]> 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 here.
--Steve
Regards, Bindul -- Bindul Bhowmik MindTree Consulting Ltd. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
