Versions Compared

Key

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

...

When explicitly constructed, an Integer object has a unique reference and its own intrinsic lock that is not shared with other Integer objects or boxed integers having the same value. While this is an acceptable solution, it can cause maintenance problems because developers can incorrectly assume that boxed integers are appropriate lock objects. A more appropriate solution is to synchronize on a private final lock Object object as described in the following compliant solution.

...