...
The Boolean
type is unsuitable for locking purposes because it allows only two values: TRUE
true and FALSE
false. 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 FALSE
false. 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.
...