3个重要方法 :
1. Interrupt() 打断线程并且设置标志位。
2.IsInterrupted() 查询某线程是否被打断。
3.static Interrupted() 查询线程是否被打断过,并且重置标志位。
一些要记住的要点 :
1. Interrupt 和sleep, wait,join 是可以配合使用的 , 并且可以设置标志位。
2. Interrupt会抛出interrupt Exception, 一般不建议和sleep配合, 但是wait和join比较常见.
3.如果使用interrupt是必须要正确响应interrupt exception的,要么忽略继续直行或者如何灵活处理 ,这里的执行逻辑完全由编写程序的程序员决定。
4.Interrupt 对于lock和synchronise的中间过程是干扰不了的 ,需要干扰则需要运用到ReentrantLock的LockInterruptibly.