摘要: java.lang.Thread类有一个 interrupt 方法,该方法直接对线程调用。当被interrupt的线程正在sleep或wait时,会抛出 InterruptedException 异常。事实上, interrupt 方法只是改变目标线程的中断状态(interrupt status),而那些会抛出InterruptedException 异常的方法,如wait、sleep、join等,都是在方法内部不断地检查中断状态的值,如果发现中断,则抛出InterruptedException异常。 阅读全文
posted @ 2024-06-14 15:37 狂盗一枝梅 阅读(276) 评论(0) 推荐(0) 编辑