title: Update JProgressBar from ExecutorService
body: <p>I am pinging gateways using Java ICMP ping function. To perform fast pinging I am using ExectorService which creates threads for pinging. After address is pinged (or not) I want to update Jprogressbar after pinging. I have this code which is working but it updates Jprogressbar before job (ping thread) is finished. I want to update jprogressbar after job is finished.</p>
  
  <pre><code>private int NUM_THREADS = Runtime.getRuntime().availableProcessors();
  ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
  public void run() {
      int JProgressBarValue = 0;
      for (;GateWayKey&lt;=GateWayKeyStop;GateWayKey++){
          ip="192.168."+GateWayKey+".1";
         exec.submit((new PingTask(ip,GateWayKey,true,scanFrameRefrence,ttl)));
         JProgressBarValue=(GateWayKey/GateWayKeyStop)*100;
         scanFrameRefrence.progressBar.setValue(JProgressBarValue);
         scanFrameRefrence.progressBar.repaint();
      }}
  </code></pre>