package int_test;
 
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JProgressBar;
 
class Watek
implements Runnable
 {
   boolean stan = true; //licz//nie licz
   public int li = 0; //stany 0..99
   public JProgressBar bar; // obiekt bar
 
   Watek(JProgressBar bar) {
     this.bar = bar;
   }
   // zmiana stanu paska ... sekwencje
   public synchronized void run() {
   while (this.stan)
     {
       this.li += 1;
       this.bar.setValue(this.li);
       if (this.li > 100) this.li = 0;
            try {
                this.wait(10);
            } catch (InterruptedException ex) {
                Logger.getLogger(Watek.class.getName()).log(Level.SEVERE, null, ex);
            }

     }
   }
 }
