From which thread should System.exit() be called in a Swing-app?

后端 未结 7 1603
情书的邮戳
情书的邮戳 2021-01-18 02:04

In a Swing-app is it okay to invoke System.exit() from any thread? (e.g. on the EDT?)

7条回答
  •  猫巷女王i
    2021-01-18 02:45

    It is safe to call System.exit from any thread but not from the shutdown hook thread. I recently had to debug such flow https://knotgillcup.blogspot.com/2019/08/systemexit-not-working.html

    Even more brutal way to terminate JVM is to call Runtime.halt() method.

提交回复
热议问题