Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8176499: Dependence on java.util.Timer freezes screen when OS time resets backwards #117

Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -26,13 +26,16 @@
package com.sun.glass.ui.monocle;

import com.sun.glass.ui.Timer;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* Monocle implementation class for Timer.
*/
final class MonocleTimer extends Timer {
private static java.util.Timer timer;
private java.util.TimerTask task;
private static ScheduledThreadPoolExecutor scheduler;
private ScheduledFuture<?> task;

MonocleTimer(final Runnable runnable) {
super(runnable);
@@ -47,19 +50,11 @@ static int getMaxPeriod_impl() {
}

@Override protected long _start(final Runnable runnable, int period) {
if (timer == null) {
timer = new java.util.Timer(true);
if (scheduler == null) {
scheduler = new ScheduledThreadPoolExecutor(1);
}

task = new java.util.TimerTask() {

@Override
public void run() {
runnable.run();
}
};

timer.schedule(task, 0, (long)period);
task = scheduler.scheduleAtFixedRate(runnable, 0, period, TimeUnit.MILLISECONDS);
return 1; // need something non-zero to denote success.
}

@@ -69,7 +64,7 @@ public void run() {

@Override protected void _stop(long timer) {
if (task != null) {
task.cancel();
task.cancel(false);
task = null;
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.