What is the cause and resolution of java.lang.ExceptionInInitializerError error when trying to open a JFrame in another Thread?

前端 未结 2 1063
遥遥无期
遥遥无期 2021-01-24 08:11

I\'m trying to creating a test class to open a JFrame. In order to stop the window from closing the moment the main thread finishes I added the code to open up the window in ano

2条回答
  •  感动是毒
    2021-01-24 08:44

    The exception message tells you exactly what is wrong: you're trying to create a new thread while the JVM is shutting down.

    The reason the JVM shuts down when the main thread finishes is because you call setDaemon(true) on your event thread. Remove that line and the JVM will stay up as long as that thread is alive.

提交回复
热议问题