From bb7ab62c7a5ef83a8f4edcfa35b1b829970d7103 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 21 Oct 2013 15:12:07 +1100 Subject: [PATCH] 419914 - QueuedThreadPool uses nanoTime --- .../eclipse/jetty/util/thread/QueuedThreadPool.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java index c116739f49d..f765f4e701d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java @@ -129,10 +129,10 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo jobs.offer(noop); // try to jobs complete naturally for half our stop time - long stopby = System.currentTimeMillis() + timeout / 2; + long stopby = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeout) / 2; for (Thread thread : _threads) { - long canwait = stopby - System.currentTimeMillis(); + long canwait = TimeUnit.NANOSECONDS.toMillis(stopby - System.nanoTime()); if (canwait > 0) thread.join(canwait); } @@ -145,10 +145,10 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo thread.interrupt(); // wait again for the other half of our stop time - stopby = System.currentTimeMillis() + timeout / 2; + stopby = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeout) / 2; for (Thread thread : _threads) { - long canwait = stopby - System.currentTimeMillis(); + long canwait = TimeUnit.NANOSECONDS.toMillis(stopby - System.nanoTime()); if (canwait > 0) thread.join(canwait); } @@ -549,8 +549,8 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo if (size > _minThreads) { long last = _lastShrink.get(); - long now = System.currentTimeMillis(); - if (last == 0 || (now - last) > _idleTimeout) + long now = System.nanoTime(); + if (last == 0 || (now - last) > TimeUnit.MILLISECONDS.toNanos(_idleTimeout)) { shrink = _lastShrink.compareAndSet(last, now) && _threadsStarted.compareAndSet(size, size - 1);