我试图了解异常如何在多线程中传播。
题
在下面的例子中。为什么RuntimeException异常没有被捕获
`System.out.println("Exception handled " + e);
Run Code Online (Sandbox Code Playgroud)
给定代码
`System.out.println("Exception handled " + e);
Run Code Online (Sandbox Code Playgroud)
JavaTpoint 中的第一个示例“中断停止工作的线程的示例”
输出
Exception in thread "Thread-0" java.lang.RuntimeException: Thread interrupted...java.lang.InterruptedException: sleep interrupted
at p05_Interrupt.D05_Interrupt1.run(D05_Interrupt1.java:9)
Run Code Online (Sandbox Code Playgroud)
是不是因为这是多线程,所以在线程中打印异常t1,main()隐藏线程的输出?
我还尝试添加 throws atpublic void run() throws RuntimeException {没有改变任何东西。