从 java 命令行运行时,以下代码可以正常工作。但是,当使用 exec:java 运行时,我从未看到该行打印...无论如何要停止这种行为?
public static void main(String[] args) throws InterruptedException {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
System.out.println("Uncaught exception: " + e.getMessage());
}
});
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
int i = 1 / 0;
}
});
Thread.sleep(1000);
System.exit(0);
}