From cea77cd081a17bcfb42d69017e2382968288b222 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Tue, 18 Nov 2014 12:11:22 +0100 Subject: [PATCH] quick debug helper hack --- src/de/teamteamteam/spacescooter/thread/TimedThread.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/de/teamteamteam/spacescooter/thread/TimedThread.java b/src/de/teamteamteam/spacescooter/thread/TimedThread.java index e2bd386..cbb4c15 100644 --- a/src/de/teamteamteam/spacescooter/thread/TimedThread.java +++ b/src/de/teamteamteam/spacescooter/thread/TimedThread.java @@ -18,6 +18,11 @@ public abstract class TimedThread extends Thread { */ private long workTime; + /** + * This is a quick hack :) + */ + private long runloops; + /** * This method sets the actual working interval based on hz. * @@ -32,6 +37,7 @@ public abstract class TimedThread extends Thread { */ public final void run() { while (true) { + this.runloops++; long workStart = System.nanoTime(); // do the actual work this.work(); @@ -41,8 +47,9 @@ public abstract class TimedThread extends Thread { long timeToWait = this.workInterval - workTime; //in case we are already running late, just print a warning and carry on! - if(timeToWait < 0) { + if(timeToWait < 0 && this.runloops > 50) { // runloops for filtering out game start delays System.err.println("[" + this.getName() + "] workTime exceeds workInterval!:" + this.workTime + " > " + this.workInterval); + runloops = 100; // overflow protect continue; } long msToWait = timeToWait / 1000000;