Yes. Monitor lock need to be put on code (preferred) or method wherever they
care accessed by more than one thread.
Example:
static void doSort (int [] arr)
{
    ..
    synchronized(arr)
    {
        // sensitive code
    }
}

.method static doSort([I)V
    aload_0
    monitorenter
    ; sensitive code
    monitorexit
    ...
    return
end method

----- Original Message -----
From: "Brandon Cruz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 12, 2001 2:18 PM
Subject: Java Question


> I have looked all over and can't find the answer to this simple question.
> If you use a static method, do you have to synchronize it in case other
> people may access it at the same time.  For example, I have a static
Utility
> class to do date calculations.  The method Utility.getMonth(String date)
> takes in a full date string, parses it, and returns just the month value.
> If 5 different people all using the website attempt to use
> Utility.getMonth(String date) at the same time for different dates, will
it
> return the right results?  If not, do I have to synchronize it or
something
> in case multiple users attempt to access it?
>
> I know this is not really related to tomcat, but since I am using tomcat,
> and everyone else using tomcat is also a java developer, I figured this is
> the best place I can ask.
>
> Thanks for any help!!!
>
> Brandon
>

Reply via email to