What happens when there is synchronization block around the usage of an object only in one place?
<pre><code>Class A {
    private Map&lt;Oject,Object&gt; map;
    public void clear() {
        map.clear();
    }

    public void work() {
        synchronized (map) {
            map.put(new Object, new Object();
        }
    }
}
</code></pre>

<p>If thread A is in the middle of the <code>work()</code> method, does this mean thread B won't block if executing the <code>clear()</code> method?</p>

<p>What is the difference between the code above and having this?</p>

<pre><code>    public void clear() {
        synchronized (map) {
            map.clear();
        }
    }
</code></pre>
