首页 > 其他分享 >Either re-interrupt this method or rethrow the "InterruptedException" that can be caught h

Either re-interrupt this method or rethrow the "InterruptedException" that can be caught h

时间:2022-09-04 15:34:07浏览次数:56  
标签:rethrow 中断 caught InterruptedException re 线程 interrupt

java interrup()函数会中断线程(本质更新线程为中断状态)。若sleep()函数检测到线程中断(interrupt()函数触发) 会抛 InterruptedException, 被catch住后线程中断状态更新为未中断

sonar检测到该问题会提示此种潜在逻辑,防止忽略该潜在风险而导致代码bug。

标签:rethrow,中断,caught,InterruptedException,re,线程,interrupt
From: https://www.cnblogs.com/acelin/p/16655208.html

相关文章