相关疑难解决方法(0)

在Java中处理InterruptedException

以下处理方式有什么区别InterruptedException?最好的方法是什么?

try{
 //...
} catch(InterruptedException e) { 
   Thread.currentThread().interrupt(); 
}
Run Code Online (Sandbox Code Playgroud)

要么

try{
 //...
} catch(InterruptedException e) {
   throw new RuntimeException(e);
}
Run Code Online (Sandbox Code Playgroud)

编辑:我也想知道这两个使用的场景.

java multithreading exception-handling interrupted-exception

283
推荐指数
6
解决办法
15万
查看次数