Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid calling System.exit from the EDT
Unfortunately, calling it from the EDT creates a deadlock. SciJava Common registers a JVM shutdown hook thread that calls dispose() on AWT windows it manages (e.g. the main ImageJ2 window), but Window#dispose() internally runs some logic via EventQueue.invokeAndWait. But meanwhile, the System.exit call triggers the shutdown hooks, which use Thread#join to wait for them to finish, thus blocking the EDT. So the invokeAndWait disposing the window can never finish. Therefore, as a workaround here, we avoid the problem by exiting the JVM from a new thread instead.
- Loading branch information