the web server/servlet engine combination (at least in the case of the JWS, and from 
the Hunter book, pg. 11)
loads a servlet ONCE.  i suspect this is part of the spec, but i haven't looked.  
thus, unless a servlet implements
SingleThreadedModel, this one instance will service all requests to the servlet.  the 
*major* implication of this:
all class (instance) variables are *not* thread safe.  the two ways around this:  
synchronize their assignment
statements, or use no class variables (that is, define all variables in methods).  
it's worth noting that a method,
servlet or otherwise, is thread safe; at least in a class which *does not* create its 
own threads.

which brings us to the second question.  *any* class can multi-thread *itself*.  this 
is a different concern from
the threadedness of the servlet vis-a-vis its server.  if one does so, then one must 
manage these threads in
the servlet code.  i've not yet found the need to do this.

robert young

On Thursday, November 11, 1999 7:26 PM, Andras Balogh [SMTP:[EMAIL PROTECTED]] wrote:
>     Hi,
>
> I am not sure that i understand you question.
> Here is my opinion:
>
>     A servlet is multithreaded as default, meaning
> that if NOT implements SingleThreadModel it will
> be multithreaded.
>     There was (and will be) a lot of discussons about
> how to make a servlet thread safe.
> I am not giving You advices because  for me eighter
> this is not clear.
>     You can check the arhives about this topic.
> Maybe a guru can do a Servlet FAQ related to
> MultiThreading in Servlets.
>
> Hope it helps.
>
> Best wishes,
>                 Andras.
>
>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: Telmo Sa <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, November 11, 1999 1:45 PM
> Subject: Multithreading servlet
>
>
> > Hello!
> > Can anyone plead send me an example code servlet using threads?
> >
> > Thank you so much!
> >
> > Telmo
> >
> >
> ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to