diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java b/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java index 5aa4990a86a..7fcb2a80265 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java @@ -1,41 +1,41 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.concurrent;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * This is an implementation of {@link Timer} that is backed by an actual system timer.
- *
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
- */
-public enum SystemTimer implements Timer {
-
- INSTANCE;
-
- private volatile long millis;
-
- private SystemTimer() {
- millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
- Thread thread = new Thread() {
-
- @Override
- public void run() {
- while (true) {
- millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- break;
- }
- }
- }
- };
- thread.setDaemon(true);
- thread.start();
- }
-
- @Override
- public long milliTime() {
- return millis;
- }
-}
+package com.yahoo.concurrent; + +import java.util.concurrent.TimeUnit; + +/** + * This is an implementation of {@link Timer} that is backed by an actual system timer. + * + * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + */ +public enum SystemTimer implements Timer { + + INSTANCE; + + private volatile long millis; + + private SystemTimer() { + millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); + Thread thread = new Thread() { + + @Override + public void run() { + while (true) { + millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); + try { + Thread.sleep(1); + } catch (InterruptedException e) { + break; + } + } + } + }; + thread.setDaemon(true); + thread.start(); + } + + @Override + public long milliTime() { + return millis; + } +} |