中断线程interrupt可以通过调用threadinterrupt对线程进行中断操作当线程收到interrupt信号后suspend和interrupt区别,可能会有两种场景线程处于运行状态将isinterrupt置为true 线程处于阻塞状态抛出InterruptedException,isinterrupt为false挂起suspend和继续执行resumeDeprecated不推荐使用,原因是如果在多线程环境中,假设多个。
1使用退出标志,也就是等待 Run 方法运行结束 2使用 stop 方法强行终止线程,但是这个方法已经过期而且是不安全suspend和interrupt区别的方式 thorw 3使用 interrupt 方法中断线程interupt方法和interupted或return结合4异常法 throw new InterruptedExceptioninterrupt方法 使用interrupt方法。
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。