Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Explicitly define the name of the class (superclass here) in the synchronization block. This can be achieved in two ways. Onw way is to explicitly pass the superclass's instance.Class.forName().

Code Block
bgColor#ccccff
synchronized(SuperclassName.class) { ... }

The second way is to use the Class.forName() method.

Code Block
bgColor#ccccff

synchronized(Class.forName("SuperclassName")) { ... }

Finally, it is important to recognize the entities with which synchronization is required rather than indiscreetly scavenging for variables or objects to synchronize on.

...