tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filip Hanik" <>
Subject RE: Java Question
Date Tue, 12 Jun 2001 22:38:06 GMT
maybe you guys should take this discussion off line or to a general Java
mailing list,
I don't really see how it is relevant to tomcat.

thanks in advance

Namaste - I bow to the divine in you
Filip Hanik
Software Architect

>-----Original Message-----
>From: Dmitri Colebatch []
>Sent: Tuesday, June 12, 2001 3:42 PM
>Subject: Re: Java Question
>Correct me if I'm wrong.  But you'd only need to synchronize if the method
>used data that was shared between threads.  If you have a method:
>	public static int getMonth(String date)
>	{
>		return dataFormatter.parse(date).get(Calendar.MONTH);
>	}
>or something like that (I can never remember the exact api), then you wont
>need to synchronize it because its not using anything (except the
>dateFormatter object) that is shared.  I cant see where you would need
>synchronization there.
>The exception to this is the situation where the argument is
>mutable (which
>String is not) and other threads may be changing it, in which case
>you might
>need to synchronize on the argument.  But I cant see why you would
>synchronize a static method as a rule of thumb.  If its a utility method,
>then let the calling class do the synchronization of the data.
>I'd like to see someone point out where I am wrong if indeed I am.
>On Wed, 13 Jun 2001 04:18, Brandon Cruz wrote:
>> 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
>> 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

View raw message