Rewrite the classes using the factory design pattern and get their respective instances in other classes using static initializers. Whether or not you need to synchronize the methods is answered by the question: If two threads gain concurrency of the object will the resultant change in state corrupt the integrity of the output?
cf., Joshua Block, "Effective Java" (Sun/Addison-Wesley 2001): 5-9 (has a great forward by Guy Steele, too). Mark -----Original Message----- From: Ashish Kulkarni [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 4:36 PM Hi Jeff, This tutorial talks about threads and when to make them synchronize, but my problem is about a kind of utility class or worker class which has 2 methods which i want to keep static so i dont have to create instance of that class to use these methods.. and i my question is i would not make them synchronized, if they are independent and do not use any other class resources, and make them synchronized if i have some class variable which is accessed bye them, so no 2 instance of classes can use the method at a time( this is off course going to affect performace) but i my doubt is, if one static method is calling other static method in same class, should i make them synchronized??? Ashish --- Jeff Kyser <[EMAIL PROTECTED]> wrote: > Ashish, > > Check out the following trail on threads at > java.sun.com, > > > http://java.sun.com/docs/books/tutorial/essential/threads/index.html > > it discusses synchronization and when you need to > use it. > > -jeff > > On Tuesday, March 11, 2003, at 02:41 PM, Ashish > Kulkarni wrote: > > > Hi, > > > > I have a following class with 2 static methods, > should > > i make the methods synchronized?? > > I would not make then synchronized, if those where independent, > > but i am not sure since one method is calling > other to > > get some data > > I will call this method from any class > > String a = MyClass.getOtherThing("123"); > > or > > String b = MyClass.getSomeThing("567"); > > (this is just a example code) > > > > public class MyClass > > { > > public static String getSomeThing(String abc) > > { > > // some logic > > return "1"; > > } > > > > public static String getOtherThing(String abc) > > { > > // calling method getSomeThing here > > String s = getSomeThing(abc); > > // do some logic and return result > > return "2"; > > } > > } > > > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Web Hosting - establish your business > online > > http://webhosting.yahoo.com > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]