(the example code below is self-contained and runnable, you can try it, it won't crash your system :)
Tom Hawtin commented on the question here: http://stackoverflow.com/questions/3018165
that:
It's unlikely that the EDT would crash. Unchecked exceptions thrown in EDT dispatch are caught, dumped and the thread goes on.
Can someone explain me what is going on here (every time you click on the "throw an unchecked exception" button, a divide by zero is performed, on purpose):
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class CrashEDT extends JFrame {
public static void main(String[] args) {
final CrashEDT frame = new CrashEDT();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing( WindowEvent e) {
System.exit(0);
}
});
final JButton jb = new JButton( "throw an unchecked exception" );
jb.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println( "Thread ID:" + Thread.currentThread().getId() );
System.out.println( 0 / Math.abs(0) );
}
} );
frame.add( jb );
frame.setSize(300, 150);
frame.setVisible(true);
}
}
I get the following message (which is what I'd expect):
Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero
and to me this is an unchecked exception right?
You can see that the thread ID is getting incremented every time you trigger the crash.
So is the EDT automatically restarted every time an unchecked exception is thrown or are unchecked exceptions "caught, dumped and the thread goes on" like Tom Hawtin commented?
What is going on here?