title: java method synchronization object
body: <p>I just wanted to be sure that I understood the following right.</p>
  
  <ol>
  <li>The synchronized keyword on methods forbids two such methods to be run simultaneously on one instance of the class.</li>
  <li>The synchronization object is the instance in question.</li>
  </ol>
  
  <p>If this is true the following example should be right</p>
  
  <pre><code>class Example
  {
    public synchronized void method1()
    {
      // mark 1 - never here when other thread at mark 2 or 4
    }
  
    public synchronized void method2()
    {
      // mark 2 - never here when other thread at mark 1 or 4
    }
  
    public void method3()
    {
      // mark 3 - may be (!) here when other thread at mark 1, 2 or 4
      synchronized (this)
      {
        // mark 4 - never here when other thread at mark 1 or 2
      }
    }
  }
  </code></pre>
  
  <p>Thx for a 'yes' or falsification.
  b</p>