> -----Original Message----- > From: Raiden [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 02, 2003 4:42 AM > To: Tomcat Users List > Subject: RE: How to synchronize based on session? (Prevent > multiple submissions of forms) > > > > On Wed, 2 Jul 2003, Stefan Radzom wrote: > > > > >IMHO, Justin's proposal will not work since the servlet > > > container may choose > > > >to pool multiple instances of the same servlet class and > > > assign an incoming > > > >request to an available instance. > > > > > > Agreed. If the container chooses to pool multiple instances > > > of the same > > > servlet (I'm assuming this can be the case with Tomcat?), > > > then you're right > > > -- it won't work. > > > > > > > Sorry, I was a bit too fast here. The spec allows pooling > of instances only > > if the servlet implements SingleThreadModel. If the class > does not implement > > STM only one instance per jvm is allowed. > > Hrm... I always thought this was opposite of what happens. I > thought we > should always assume that there will be multiple instances of of our > servlet in existance (for purposes of pooling), and as such, > our service > methods must take that into account. > > It seems strange that Tomcat would only use a single instance > of a servlet > across all requests if a servlet does not implement STM. It > would appear > to be a major bottleneck. In fact, I thought that's the > purpose of STM... > for cases in which you're ok with the bottleneck, but you > want to ensure > that there is only one thread ever accessing that servlet at > a given time > (which would also imply that there is only one instance of > the servlet). >
Just to clarify some things. If your servlet _does not_ implement STM there will be only one instance per jvm. However, there will be no bottleneck since multiple threads may execute in the service method at a time. If your servlet instead _does_ implement STM you are guaranteed that only one thread will execute in the service method at a time. To compensate for this bottleneck pooling of instance is allowed. Viewed from this perspective the spec absoultely does make sense. -Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
