VirtualBox

Ticket #5973: TimerTest.java

File TimerTest.java, 729 bytes (added by Harald, 15 years ago)
Line 
1public class TimerTest {
2
3 public static void main(String[] args) throws Exception {
4 while(true) {
5 long start = System.currentTimeMillis();
6 long startNanos = System.nanoTime();
7 Thread.sleep(5000);
8 long end = System.currentTimeMillis();
9 long endNanos = System.nanoTime();
10 if (end < start) {
11 System.out.println("Millis Panic! Start:" + start + " End:" + end + " (@ " + new java.util.Date() + ")");
12 }
13 if (endNanos < startNanos) {
14 System.out.println("Nanos Panic! Start:" + startNanos + " End:" + endNanos + " (@ " + new java.util.Date() + ")");
15 }
16 }
17 }
18}

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy