JAL-4217 try really hard to shut down and dispose of Desktop resources and any lurkin...
authorJames Procter <j.procter@dundee.ac.uk>
Fri, 30 Jun 2023 11:58:55 +0000 (12:58 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Fri, 30 Jun 2023 11:58:55 +0000 (12:58 +0100)
src/jalview/gui/Desktop.java

index b901ae4..36d6434 100644 (file)
@@ -3623,8 +3623,22 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
       Desktop.instance.closeAll_actionPerformed(null);
       Desktop.instance.setVisible(false);
-      Desktop.instance.dispose();
+      Desktop us = Desktop.instance;
       Desktop.instance = null;
+      // call dispose in a separate thread - try to avoid indirect deadlocks
+      new Thread(new Runnable() {
+        @Override
+        public void run()
+        {
+          ExecutorService dex = us.dialogExecutor;
+          if (dex!=null) {
+            dex.shutdownNow();
+            us.dialogExecutor=null;
+            us.block.drainPermits();
+          }
+          us.dispose();
+        }
+      }).start();
     }
   }