> From: Carl Dreher [mailto:focus...@arn.net] > Subject: Re: threads vs. servlets
> > > If I write a servlet such as the above, is there ever only once instance > > > of it running? > > Don't confuse objects with threads. There is one instance of a particular > > servlet, but > > many threads may be executing in it concurrently, with each thread > > processing a separate > > request. > But does each thread have its own copy of the servlet code? Why would anyone ever duplicate _code_? Perhaps you mean the instance fields of the servlet object? > Or does each thread request the use of the servlet, wait until it is > available, use it, and > then release it back to be used by the next thread, sort of like a database > connection? Note the use of the word "concurrently" above; is that not clear? Since the threads are executing at the same time within the servlet, one should be very, very careful about using instance or static fields during request processing. Such mistakes are a common cause of garbled responses. - 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: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org