This is true; however, *for the most part* (this is NOT a written guarantee,
so by all means, conduct your testing thoroughly!), you'll be safe if you
access only local variables *within your current method*.
Multithreading can be a tricky issue to debug, so if at any time you need to
access something outside the current method (a la Milt's file example,
below), figure on synchronizing access to it. This synchronization may be a
Java monitor (using the "synchronized" keyword), or it may be a file-guard
on disk, or it may even be a JNI-accessed OS-level IPC element, like NT's
Events, Mutexes or Semaphores, if necessary. (You would only need the latter
when trying to interact concurrently with a native Win32 app that regulated
its access to something via an NT-specific IPC element.)
For general multithreading issues, Doug Lea's "Concurrent Programming in
Java" is by far the best book on threads (in ANY language) around.
Ted Neward
Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
http://www.javageeks.com/~tneward
"I don't even speak for myself; my wife won't let me." --Me
-----Original Message-----
From: Milt Epstein <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, July 06, 1999 9:18 PM
Subject: Re: Can some explain/confirm
>On Tue, 6 Jul 1999, Nitin Mangtani wrote:
>
>> yah you are right if there are no instance variables and all are
>> local variables then you need not worry about synchronization
>> issues.
>
>I don't want to get into this too deeply, because it is not all that
>simple and it has been discussed here before (try checking the
>archives), but basically I don't think things are as simple as the
>above suggests. Avoiding class/instance variables and sticking with
>local variables will help you avoid synchronization issues regarding
>those variables. However, there may be other synchronization issues
>to worry about, like say with some shared resource. For example, if
>the servlet manipulates a file (e.g. writing to it), there's a
>potential synchronization issue there.
>
>
>> 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? 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 ?
>>
>> Normally one does not use SingleThread Model because if restricts
>> the usage to only one client at a given time. But if you have some
>> critical resource which has to be shared across multiple clients and
>> you want only one client can acces it then you go for it.
>
>Milt Epstein
>Research Programmer
>Software/Systems Development Group
>Computing and Communications Services Office (CCSO)
>University of Illinois at Urbana-Champaign (UIUC)
>[EMAIL PROTECTED]
>
>___________________________________________________________________________
>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