据我所知,在线程内部检查线程是否收到中断信号有两种方法,Thread.interrupted()
和Thread.isInterrupted()
,它们之间唯一的区别是前者重置了内部中断标志。
到目前为止,我一直在使用Thread.isInterrupted()
,从来没有遇到过任何问题。话又说回来,我看过的大多数教程都推荐使用Thread.interrupted()
。有什么特别的原因吗?
https://stackoverflow.com/questions/1904072
复制相似问题