title: Detecting that JVM is shutting down
body: <p>I have a Swing application that handles Ctrl+C using addShutdownHook(), and it works fine until one of the shutdown tasks I have calls a function that under normal circumstances changes a JLabel text, at which point it hangs.</p>
  
  <p>I assume the problem is that the Swing EDT has either terminated or is waiting for something.</p>
  
  <p>Is there a way to either determine that the EDT has terminated or is "done" (so I can avoid calling Swing methods), or to prevent the usual close-all-the-windows-down behavior on Ctrl-C?</p>
  
  <hr>
  
  <p>Just to clarify:</p>
  
  <p>I have a method in a class called <code>stop()</code>. Under normal circumstances this can get called (along with its complement <code>start()</code>) and it triggers a cascade of things that causes a JLabel to be updated, for visual feedback that a <code>stop()</code> has occurred.</p>
  
  <p>When my shutdown hook runs, I need to call <code>stop()</code> to gracefully shutdown some resources. </p>
  
  <p>What I'm asking is how I can detect that Swing EDT is not there, so I can rewrite <code>stop()</code> so that it detects a lack of Swing and avoids the call to the Swing functions.</p>