title: How to stop the main thread and wait until an opened popup form disposes in JAVA?
body: <p>I have 2 classes: <code>control</code> and <code>popup</code>. I run a loop to and call 3 jframe forms.
  I want on the main control class, it must stop and wait until a popup disposes before continue the loop and open another one. How can I achieve this?</p>
  
  <p>I tried to create add an <code>extraThread</code> to run the popup and use <code>extraThread.join()</code> but it still doesn't work.</p>
  
  <p><strong>control</strong></p>
  
  <pre><code>package main;
  
  public class control {
      public static void main(String[] args) {
          for(int i = 0; i &lt; 3; i++) {
              popup pop = new popup();
              System.out.println("" + i);
              pop.show();
          }
      }
  }
  </code></pre>
  
  <p><strong>popup</strong></p>
  
  <pre><code>package main;
  
  import java.awt.SystemColor;
  
  import javax.swing.JFrame;
  
  public class popup {
  
      private JFrame frmpopup;
  
      public popup() {
          initialize();
      }
  
      private void initialize() {
          frmpopup = new JFrame();
          frmpopup.getContentPane().setBackground(SystemColor.controlHighlight);
          frmpopup.setTitle("Standard Form");
          frmpopup.setBounds(100, 100, 224, 269);
          frmpopup.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      }
  
      public void show() {
          frmpopup.setVisible(true);
      }
  }
  </code></pre>