From 74c36ac68e07e85da17fc5897ddb3bda4075084a Mon Sep 17 00:00:00 2001 From: James Procter Date: Fri, 30 Jun 2023 12:58:55 +0100 Subject: [PATCH] JAL-4217 try really hard to shut down and dispose of Desktop resources and any lurking threads --- src/jalview/gui/Desktop.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index b901ae4..36d6434 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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(); } } -- 1.7.10.2