If you are *only* using local variables you are correct, you don't need to
worry about thread protection of those variables. Only shared
variables/resources need to be protected. However as soon as you step
outside this constraint threads do become an issue (see the very recent
discussion here about thread safety and sessions for example).

SingleThreadModel could be used to limit the number of threads in your
servlet service method to one - this has limitations however - the most
obvious being that you severely limit the scalability of your servlet, you
will nearly always be better off understanding and managing the threading
issues yourself rather than let the servlet engine do it (which is the
effect of SingleThreadModel). Also, SingleThreadModel may not give you
exactly what you want - it limits the number of threads in an instance of a
servlet, a servlet engine could have more than one instance of a servlet
managing requests for this web server (unlikely but possible), or could have
multiple instances of a servlet running on multiple web-servers (very
likely) - in both of these scenarios you still need to be aware of thread
issues.

Kevin

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Jeetandra Mahtani
Sent: 06 July 1999 13:53
To: [EMAIL PROTECTED]
Subject: Can some explain/confirm


Hello,
Can someone please confirm the following and maybe provide some insight to
make my
concepts thorough.
If there are no instance variables and only local variables, one does not
need to worry
about different threads accessing the same variable, right?
If only local variables are being used in all classes, does one need to
worry about
synchronization/thread issues?
When does one need to use the SingleThread Model ?
Thanks for any information.
J

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___________________________________________________________________________
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