Versions Compared

Key

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

...

The Boolean type is unsuitable for locking purposes because it allows only two values: TRUE true and FALSEfalse. Boolean literals containing the same value share unique instances of the Boolean class in the JVM. In this example, initialized references the instance corresponding to the value FALSEfalse. If any other code inadvertently synchronizes on a Boolean literal with the value FALSE, the lock instance is reused and the system can become unresponsiveness or deadlocked.

...