Jeetandra Mahtani wrote:
>
> 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?
Right. Variables declared in a method ("local variables") are created when
the method is called, so each thread has its own copy and there's no way
they can interfere with each other.
> If only local variables are being used in all classes, does one need to worry about
> synchronization/thread issues?
No, see the answer above. But if your method accesses some "external resource"
as well (a file, an object stored in the session or the servlet context, etc.) you
must make sure that the external resource is able to handle multithreaded
access.
> When does one need to use the SingleThread Model ?
Good question ;-) For very simple cases when you use instance variables
(e.g. a counter) STM may be useful. But it's not scalable and it's IMHO
always better to solve the threading issues instead of using STM.
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.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