So long as your code isn't referencing any variables stored within the class
itself, no, you should have no problems with thread-synchronization. It's
only when you're using a member of a class in more than one thread that you
may need to synchronize:

public class NoSynchronization
{
    public void doSomething()
    {
        // References no class members; everything's method-local.
        // Should be OK.
    }
}

public class NeedsSynchronization
{
    private String member1;
    private int member2;

    public void doSomething()
    {
        ... this.member1;
        ... this.member2;

        // Because this references the members of this instance, and
multiple
        // threads may be executing through here (and modifying the same
data)
        // at once, you need to synchronize this method.
    }
}

The same, obviously, holds true if you access static members. Note that this
*also* holds true if you access other stateful classes that aren't
thread-protected or thread-specific.

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: Jeetandra Mahtani <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, July 06, 1999 5:44 AM
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