Re: How can I make class level synchronization?
Wednesday, January 18, 2006 11:57 AM
No, there will be two instances of class C having their own set of variables that are processed in their m1 & m2 methods. The puropose of synchronization is to ensure the integrity of the variables that are processed by the synchronized method.
If your scenario involves processing that has to be synchronized in all the instances of class C (e.g. c1.m1 must not do this processing while c2.m1 executes), then I would suggest that you wrap this processing in a separate class, B, that has only one instance, and pass that instance to the C class. In the B class you then code the must-be-synchronized-processing in a synchronized method (or two...)