title: Getting Amazing Exception with Threading In Java Swing
body: <p>I am getting the following amazing exception when I am using multi-threading in my code but, I can not figure out where it occurs. Also this exception occurs only sometimes.</p>
  
  <blockquote>
    <p>Exception in thread "AWT-EventQueue-0"
    java.util.NoSuchElementException: Vector Enumeration at
    java.util.Vector$1.nextElement(Vector.java:348) at
    javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:793)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1660)</p>
  </blockquote>
  
  <p>I am using the below code for multi-threading in my application.</p>
  
  <pre><code>       try {
          Thread Thread4 = new Thread() {
             public void run() {
                  GetOrderData(mID, "OrderInfo_Orn");
              }
          };
          Thread4.start();
          Thread4.sleep(20);
  
          Thread Thread5 = new Thread() {
             public void run() {
                  GetOrderData(mID, "OrderInfo_Parts");
              }
          };
          Thread5.start();
          Thread5.sleep(20);
          Thread queryThread = new Thread() {
  
              public void run() {
                  GetMasterData(mID, rowId);
              }
          };
          queryThread.start();
          queryThread.sleep(20);
          Thread Thread2 = new Thread() {
              public void run() {
                  GetDetailData(mID, "'RcvPrePolishGoods_Detail'");
              }
          };
          Thread2.start();
          Thread2.sleep(20);
  
          Thread Thread3 = new Thread() {
              public void run() {
                  GetDetailData(mID, "'RcvPrePolishGoods_Parts'");
              }
          };
          Thread3.start();
          Thread3.sleep(20);
        } catch (InterruptedException ex) {
          Logger.getLogger(RcvPrePolishGoods.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>