title: synchronized(this) blocks whole object?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/574240/synchronized-block-vs-synchronized-method">synchronized block vs synchronized method?</a>  </p>
  </blockquote>
  
  
  
  <p>From accepted answer to this question: <a href="https://stackoverflow.com/questions/416183/in-java-critical-sections-what-should-i-synchronize-on#416198">In Java critical sections, what should I synchronize on?</a>
  I learn that </p>
  
  <pre><code>public synchronized void foo() {
      // do something thread-safe
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>public void foo() {
      synchronized (this) {
          // do something thread-safe
      }
  }
  </code></pre>
  
  <p>do exactly the same thing. But in first case we make synchronized only one method of object, and in second case we make inaccessible Whole object. So why this two code snippests do same things? </p>