58
58
//----------------------------------- Features for virtual/application time:
60
60
/** Watchdog thread for application time handling. */
61
private static Thread ticker;
64
// (ticker = new HiddenThread()).start();
65
ticker = new HiddenThread();
61
// private static Thread ticker;
64
// // (ticker = new HiddenThread()).start();
65
// ticker = new HiddenThread();
68
68
/** Tick counter for hidden thread below. */
69
69
static transient volatile int seq;
248
248
* Thread used to detect suspended JVM execution.
250
private static class HiddenThread extends java.lang.Thread {
250
// private static class HiddenThread extends java.lang.Thread {
253
* Increment <code>time</code> (used by
254
* <code>RTSystem.currentTimeMillis()</code>) each tick, keeping
255
* it within the tolerance <code>tol</code> from system time by
256
* adjusting the internal <code>lag</code>.
259
setPriority(MAX_PRIORITY);
260
systime = System.currentTimeMillis();
261
long next = systime + tickMillis; // Next real time for time update.
263
next = next / tickMillis * tickMillis; // Truncate for nicer values.
265
while (!interrupted()) {
266
System.out.println("HiddenThread is running");
270
systime = System.currentTimeMillis();
271
dt = systime - next; // Detected lag increase.
272
if (dt > tol) { // if real time too far ahead.
273
dt = (dt / tickMillis + 1) * tickMillis;
282
catch (InterruptedException exc) {
283
System.out.println("Ticker terminated!");
253
// * Increment <code>time</code> (used by
254
// * <code>RTSystem.currentTimeMillis()</code>) each tick, keeping
255
// * it within the tolerance <code>tol</code> from system time by
256
// * adjusting the internal <code>lag</code>.
258
// public void run() {
259
// setPriority(MAX_PRIORITY);
260
// systime = System.currentTimeMillis();
261
// long next = systime + tickMillis; // Next real time for time update.
263
// next = next / tickMillis * tickMillis; // Truncate for nicer values.
265
// while (!interrupted()) {
266
// System.out.println("HiddenThread is running");
267
// dt = next - systime;
270
// systime = System.currentTimeMillis();
271
// dt = systime - next; // Detected lag increase.
272
// if (dt > tol) { // if real time too far ahead.
273
// dt = (dt / tickMillis + 1) * tickMillis;
278
// next += tickMillis;
282
// catch (InterruptedException exc) {
283
// System.out.println("Ticker terminated!");