What I said in the comment was partly wrong. Actually Java 7 Docs sais:
If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException.
Source: http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()
So, the InterruptedException being thrown clears the status, not catching it.
Seen effect is the same. When i=1 the flag is set by interrupt()
and executing sleep
will lead to the flag being cleared and the exception thrown which leads to seen output.
Also see: http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#sleep(long)