同步块/方法是否可以中断?
  虽然我知道Re-EntrantLocks和synchronized之间的理论差异,但我对以下几点感到困惑。 
  从JavaRevisited比较synchronized和Lock对象的文章中看到这个陈述: 
在Java中,ReentrantLock和synchronized关键字之间还有一点值得注意的是,能够在等待锁定时中断Thread。 在同步关键字的情况下,一个线程可以被阻塞等待锁定,无限期的时间,并且没有办法控制它。 ReentrantLock提供了一个名为lockInterruptibly()的方法,它可以在等待锁定时中断线程。 类似地,如果在特定时间段内锁定不可用,则可以使用带有超时的tryLock()超时。
按照上面的说法,我尝试在synchronized方法(即阻塞等待)上中断Thread waiting(),并且它确实抛出了InterruptedException。 但是这种行为与上述声明中的内容矛盾。
// 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();
这是我得到的输出:
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)  
如果我的示例不正确或者关于synchronized()的引用语句不正确,我很困惑。
你不中断同步,你正在中断sleep() 。 
