Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added CON04-J ref to intro

Static shared data should not be protected using instance locks because the instance locks are ineffective when two or more instances of the class are created. Consequently, the shared state is not safe for concurrent access unless a static private final lock object is used. Ideally, the lock should also be private and final, as per CON04-J. Use private final lock objects to synchronize classes that may interact with untrusted code.

Noncompliant Code Example (non-static lock object for static data)

...