title: Why is it not a good practice to synchronize on Boolean?
body: <p>My architect always says that </p>
  
  <blockquote>
    <p>Never synchronize on Boolean</p>
  </blockquote>
  
  <p>I am not able to understand the reason why and would really appreciate if someone could explain with an example as to why it is not a good practice. 
  <a href="http://www.theothertomelliott.com/node/40">Reference Sample Code</a></p>
  
  <pre><code>private Boolean isOn = false;
  private String statusMessage = "I'm off";
  public void doSomeStuffAndToggleTheThing(){
  
     // Do some stuff
     synchronized(isOn){
        if(isOn){
           isOn = false;
           statusMessage = "I'm off";
           // Do everything else to turn the thing off
        } else {
           isOn = true;
           statusMessage = "I'm on";
           // Do everything else to turn the thing on
        }
     }
  }
  </code></pre>