From: James Procter Date: Fri, 30 Jun 2023 11:58:55 +0000 (+0100) Subject: JAL-4217 try really hard to shut down and dispose of Desktop resources and any lurkin... X-Git-Tag: Release_2_11_4_0~256 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=74c36ac68e07e85da17fc5897ddb3bda4075084a;p=jalview.git JAL-4217 try really hard to shut down and dispose of Desktop resources and any lurking threads --- 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(); } }