Java 线程 interrupt 详解

620 阅读1分钟

对于使用Java的开发者而言,线程的interrupt并不陌生。然而,你真正彻底理解它了么?

下面这篇文章将从以下几个方面,带你更清晰的理解。

interrupt() 方法的作用是什么?

对一个线程调用 interrupt() 后,它一定会中断么?

如果不能保证中断,那 interrupt() 的真正作用是什么呢?

InterruptedException 具体在什么场景下会出现?

捕获 InterruptedException 不做任何处理可以吗?

一起学习吧~

Java 线程 interrupt 详解