title: Check if thread is EDT is necessary?
body: <p>I have an UI implemented with Swing. One component does some work that may take some time, so I use <code>SwingUtilities.invokeLater</code>. However, I was reading some old code and found this in an <code>ActionListener</code>:</p>
  
  <pre><code>if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               // code X
           }
      });
  } else {
     // code X
  }
  </code></pre>
  
  <p>I thought that it made sense since it separates <code>code X</code> from the EDT. However, I found it error-prone since I have used it a couple of times and both times I forgot the <code>else</code> part.</p>
  
  <p>The question is: is the <code>SwingUtilities.isEventDispatchThread()</code> checking necessary? Or could I <strike>assume that I am not in the EDT and</strike> always use <code>invokeLater</code>?</p>
  
  <p>Thanks a lot.</p>