In a Swing-app is it okay to invoke System.exit()
from any thread? (e.g. on the EDT?)
You should not be calling System.exit()
if you can help it.
The best way to exit a java process is to let all threads exit normally. This will terminate the VM.
In your main JFrame
, you should setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
.
Then you can call frame.dispose()
to close the JFrame
and exit the EDT.