title: How to update java GUI from Thread?
body: <pre><code> private void StartActionPerformed(java.awt.event.ActionEvent evt) {
  
          Queue queue=new Queue();
          int target=Integer.parseInt(Target.getText());
          String path=Path.getText();
          final Producer p=new Producer(queue, target);
          Consumer c=new Consumer(queue);
          p.start();
          c.start();
  
          while(p.finish !=true)
          {
            Runnable r = new Runnable() {
              public void run() {
                ProgressPrecent.setValue(Producer.ProgressPercent);
              }
            };
            if(EventQueue.isDispatchThread()) {
              r.run();
            }
            else {
              EventQueue.invokeLater(r);
            }
         }
   }
  </code></pre>
  
  <p>I have two classes that have a shared Queue. one of them is Producer that produces till a target other one consume those elements. all of two extends  Thread. I want to display the progress percent to the user, but it freeze my GUI so what should I do? </p>