title: It is better to have a synchronized block inside a try block or a try block inside a synchronized block?
body: <p>For example, is this better?</p>
  
  <pre><code>try {
      synchronized (bean) {
          // Write something              
      }
  } catch (InterruptedException e) {
      // Write something
  }
  </code></pre>
  
  <p>Or it's better this:</p>
  
  <pre><code>synchronized (bean) {
      try {           
          // Write something              
      }
      catch (InterruptedException e) {
          // Write something
      }
  }
  </code></pre>
  
  <p>I was wondering which one is best practice. Obviously considering I have to synchronize all the code inside the try block. I'm not talking about the case I've to synchronize only part of the code inside the try (in this case I think it would be better to have the synch block inside the try). My doubts are about the case where I've to synchronize all the try block.</p>