Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: separated CS

...

This does not mean that it is required to synchronize on the Class object of the base class.

Compliant Solution (1) (class name qualification)

Explicitly define the name of the class (superclass in this example) in the synchronization block. This can be achieved in two ways. One way is to explicitly pass the superclass's instance.

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

Compliant Solution (2) (Class.forName())

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

...