title: Synchronized block and monitor objects
body: <p>Hi can someone explain if the in the following code the synchronized code will restrict access to the threads. If yes how is it different from, if we have used "this" as a monitor object instead of "msg".</p>
  
  <pre><code>public void display(String msg)    
  {    
      synchronized(msg)    
      {    
          for(int i=1;i&lt;=20;i++)    
            {    
                 System.out.println("Name= "+msg);    
            }  
      }   
  }
  </code></pre>