package lt.bit.laikas; import javax.swing.*; import java.util.Timer; public class Laikas extends Thread { private volatile boolean running=false; private volatile boolean terminate=false; private int time=0; private JLabel out; public Laikas(JLabel out) { this.out = out; } public void run(){ while (!terminate){ if (running) { time++; out.setText(time/10+"."+time%10); try { sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } } public boolean isRunning() { return running; } public void setRunning(boolean running) { this.running = running; } public boolean isTerminate() { return terminate; } public void setTerminate(boolean terminate) { this.terminate = terminate; } public void reset(){ time=0; running=false; out.setText("0.0"); } }