| Author |
Synchronizing Method
|
Pradeep Swaminathan
Greenhorn
Joined: Aug 25, 2005
Posts: 8
|
|
Hi, I have two classes (ClassA.java and ClassB.java) accessing static method (getSeq()) of a third class (ClassC.java). How do I synchronize, so that only one instance accesses the method at a time. Synchronizing on the class name doesn�t work. Thanks� Pradeep
|
Pradeep
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24039
|
|
Mark the method synchronized: public static synchronized void getSeq() ... That's all you need to do. It's the java.lang.Class object for the class that is used as the lock -- not the name of the class.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Synchronizing Method
|
|
|