Hello

> how the webserver handles more than one
> request at the same time.

The answer is: by invoking the servlet's service method in a new thread for
each new request to that servlet.

Think of any Java object, instantiated once - a public method in that object
can be called any number of times, concurrently. Each invocation will be
processed in a new thread.

Synchronisation is an issue only when the method in question uses references
to other objects. If the method only works with local variables, there is no
synchronisation problem!

So, in a nutshell: with servlets, make sure the service method only uses
local variables, including, of course, those two most useful parameters, the
request and the response objects.

Regards

Harry Mantheakis
London, UK


> Hi all,
> 
> may be not the right place to ask this question. Hope somebody is kind
> enough to clarify this doubt of mine.
> 
> i understand, in  a servlet, if i need any code to be thread safe, then
> i shud put that code inside a synhronized block
> or declared the entire method as synchronized. if my understanding is
> right, only instance of our serlvet class is being
> created. in that case how the webserver handles more than one request at
> the same time. i mean, is some queuing structure
> being followed, (i am tempted to believe it is not multithreaded)?
> 
> Could anybody clarify this doubt of mine or atleast point out some ref.
> material for this.
> 
> Thanks
> R.Saravanan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to