title: Why should SwingUtils.invokeAndWait() method be called outside an EDT thread?
body: <p><strong>Edit</strong> : I have referred this <a href="https://stackoverflow.com/questions/5499921/invokeandwait-method-in-swingutilities">link</a> and I'm able to understand the codeflow of InvokeLater. My question is, why is this logic implemented this way? Are there any specific reasons?</p>
  
  <hr>
  
  <p>Following is my code:</p>
  
  <pre><code>  private void init() 
      {
      JFrame jfr = new JFrame();
      jfr.setSize(500, 500);
      jfr.setVisible(true);
      jfr.setTitle("Test");
  
  
      JButton jb = new JButton("Ok");
      jfr.add(jb);
  
      jb.addActionListener(new ActionListener()
      {
          @Override
          public void actionPerformed(ActionEvent e)
          {
              try 
              {
                  SwingUtilities.invokeAndWait(new Runnable() 
                  {
                      @Override
                      public void run() 
                      {
                          System.out.println("hello");
                      }
                  });
              } 
              catch (Exception e1) 
              {
                  e1.printStackTrace();
              } 
          }
      });
  </code></pre>
  
  <p><strong>First Question</strong> (While using <code>InvokeAndWait</code>):</p>
  
  <p>Why is it implemented in such a way that it throws an <code>InvocationTargetException</code> when called within EDT Thread? </p>
  
  <p><strong>Second Question</strong> (while using <code>InvokeLater</code>):</p>
  
  <p>Why InvokeLater allows this ?</p>
  
  <p><strong>Well, this is my basic understanding on EDT threads:</strong></p>
  
  <p><strong><em>InvokeAndWait</em></strong>:</p>
  
  <ul>
  <li>Places job F into the EDT event queue and waits until the EDT has
  executed it. </li>
  <li>This call blocks until all pending AWT events(A, B, C,    D, E) have
  been processed and (then) execute F after which the    control
  returns.</li>
  <li>Returns if and only if the job submitted is completed.(Control
  returns after F is completed.)</li>
  <li>Technically, a Synchronous blocking call.</li>
  </ul>
  
  <p><strong><em>InvokeLater</em></strong>:</p>
  
  <ul>
  <li>Places the job F into the EDT Queue , but doesn't wait for its
  completion.(Basically , a publish and return call).</li>
  <li>If we don't care about the job completion we can use InvokeLater.</li>
  <li>Technically, a Asynchronous non-blocking call.</li>
  </ul>