KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > net > Timer


1 package org.sapia.ubik.net;
2
3
4 /**
5  * @author Yanick Duchesne
6  *
7  * <dl>
8  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
9  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
10  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
11  * </dl>
12  */

13 public class Timer {
14   private long _start = System.currentTimeMillis();
15   private long _duration;
16   private long _total;
17
18   public Timer(long duration) {
19     _duration = duration;
20   }
21
22   public void start() {
23     _start = System.currentTimeMillis();
24   }
25
26   public boolean isOver() {
27     _total = (_total + System.currentTimeMillis()) - _start;
28     _start = System.currentTimeMillis();
29
30     return _total > _duration;
31   }
32 }
33
Popular Tags