From e7d7b2302cd836f4a9ddbde6fd3e71e7f14c0e9d Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 4 Feb 2018 19:31:43 +0100 Subject: Fix exec duration timing Signed-off-by: pacien --- src/main/java/fr/umlv/java/wallj/viewer/Viewer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/fr/umlv') diff --git a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java index 6b4f5c4..5a7d869 100644 --- a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java +++ b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java @@ -47,12 +47,13 @@ public final class Viewer { events.clear(); events.addAll(newEvents); //add the new events returned by updates }); - lastExecDuration = FRAME_DURATION.minus(stopWatch.peek()); try { - if (!lastExecDuration.isNegative()) Thread.sleep(lastExecDuration.toMillis()); + Duration sleepDuration = FRAME_DURATION.minus(stopWatch.peek()); + if (!sleepDuration.isNegative()) Thread.sleep(sleepDuration.toMillis()); } catch (Exception e) { applicationContext.exit(-1); } + lastExecDuration = stopWatch.peek(); } applicationContext.exit(0); } -- cgit v1.2.3