title: Can a synchronized block/method be interrupted?
body: <p>While I know the theoretical differences between Re-EntrantLocks and <code>synchronized</code>, I'm confused to the below point.</p>
  
  <p>See this statement from an article on Javarevisited comparing <a href="http://javarevisited.blogspot.de/2013/03/reentrantlock-example-in-java-synchronized-difference-vs-lock.html" rel="noreferrer"><code>synchronized</code> and <code>Lock</code> objects</a>:</p>
  
  <blockquote>
    <p>One more worth noting difference between ReentrantLock and
    synchronized keyword in Java is, ability to interrupt Thread while
    waiting for Lock. In case of synchronized keyword, a thread can be
    blocked waiting for lock, for an indefinite period of time and there
    was no way to control that. ReentrantLock provides a method called
    lockInterruptibly(), which can be used to interrupt thread when it is
    waiting for lock. Similarly tryLock() with timeout can be used to
    timeout if lock is not available in certain time period.</p>
  </blockquote>
  
  <p>As per the above statement, I did try interrupting the Thread waiting() on synchronized method (i.e blocking wait) and it did throw an InterruptedException. But this behavior is contradictory with what is stated in the above statement.</p>
  
  <pre><code>// this method is called from inside run() method of every thread. 
  public synchronized int getCount() {
          count++;
          try {
              Thread.sleep(3000);
              System.out.println(Thread.currentThread().getName() + " gets " + count);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
          return count;
  }
  
  ....
  ....
  t1.start();
  t2.start();
  t3.start();
  t4.start();
  
  t2.interrupt();
  </code></pre>
  
  <p>Here is the output that I got : </p>
  
  <pre><code>Thread 1 gets 1
  Thread 4 gets 2
  Thread 3 gets 3  
  java.lang.InterruptedException: sleep interrupted
      at java.lang.Thread.sleep(Native Method)
      at locks.SynchronizedLockInterrupt.getCount(SynchronizedLockInterrupt.java:10)  
      at locks.SynchronizedLockInterrupt$2.run(SynchronizedLockInterrupt.java:35)  
      at java.lang.Thread.run(Unknown Source)  
  </code></pre>
  
  <hr>
  
  <p>I'm confused if my example is not correct or the quoted statement about synchronized() is incorrect?</p>