Your best bet for understanding multithreading issues is to get a good
understanding of the JVM.

On 6/8/05, Michael Pasko <[EMAIL PROTECTED]> wrote:
> Thanks Chuck, that was exactly the problem.  I was under the very poor
> assumption that a new thread and newly instantiated servlet object was
> created every time a request was made, instead of all threads working on
> only one instance of an object.  To mimic the desired behavior I've fixed
> the problem by adding this (implements SingleThreadModel)...
> 
> public class ServletName implements SingleThreadModel
> 
> Now it would seem that if several 100 people were to access a servlet that
> every time the following code was hit by a new thread:
> 
> PrintWriter out = response.getWriter();
> 
> It would direct all output (using out.println()) from all threads to the
> most recent person to access the servlet.
> 
> Follow up question:  With this in mind, what is the most common method of
> writing thread safe code?
> 
> Thank you very much for your help.
> 
> -Mike
> 
> -----Original Message-----
> From: Caldarale, Charles R [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 07, 2005 1:15 PM
> To: Tomcat Users List
> Subject: RE: Servlet Concurrency Issues
> 
> > From: Michael Pasko [mailto:[EMAIL PROTECTED]
> > Subject: Servlet Concurrency Issues
> >
> > I started allowing other users on it, I stumbled on some problems.
> > Basically what happens, when user A submits the form, and then 2
> > seconds later user B submits the same form.  User A stops getting
> > results, and User B receives the output for his request as well as
> > the end of User A's request.
> 
> Probably not a configuration problem but rather implementation errors in
> your servlet or some related object (such as the DB connection).
> There's normally only one copy of the servlet object, and it will be
> used concurrently by multiple threads.  Make sure you're not storing
> request-specific information in there.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> 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]
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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

Reply via email to