Regarding timer class implementation
<p>I have written the below java class which will act as a sort of timer and will print a simple statement if time limit exceeds, Please advise is there any better way also or java has provided some advance feature's also , Please advise...and it would be a great help if some also convert my code and post as I have done that will make understanding more clear.</p>

<pre><code> public class UpdateTimer implements Runnable {

        private long startTime = 0;
        private boolean running = false;

        public void startTimer() {
          this.startTime = System.currentTimeMillis();
          this.running = true;
        }

        public void stopTimer() {
          this.running = false;
        }


         // this method returns the elapsed time in seconds

        public long getElapsedTimeSecs() {
          long elapsed = 0;
          if (running) {
            elapsed = ((System.currentTimeMillis() - startTime) / 1000);
          }
          return elapsed;
        }

        public void run() {
          // set the start time
          startTimer();

          while (running) {
            if (getElapsedTimeSecs() &gt; 3000) {
              running = false;

              System.out.println("Time out since time is greater than 3000 ");
            }
          }
          try {
            Thread.sleep(6000);
          } catch (InterruptedException e) {
            log.logError("UpdateTimer thread interrupted", e);
          }
        }

      }
</code></pre>
