home *** CD-ROM | disk | FTP | other *** search
- package sun.awt;
-
- public class ScreenUpdater extends Thread {
- private final int PRIORITY = 4;
- private ScreenUpdaterEntry first;
- public static final ScreenUpdater updater = newScreenUpdater();
-
- static ThreadGroup findSystemThreadGroup() {
- Thread thread = Thread.currentThread();
-
- ThreadGroup group;
- for(group = thread.getThreadGroup(); group != null && !group.getName().equals("main"); group = group.getParent()) {
- }
-
- return group;
- }
-
- static ScreenUpdater newScreenUpdater() {
- SecurityManager.setScopePermission();
- return new ScreenUpdater(findSystemThreadGroup(), "ScreenUpdater");
- }
-
- private ScreenUpdater(ThreadGroup group, String name) {
- super(group, name);
- ((Thread)this).start();
- }
-
- private ScreenUpdater() {
- ((Thread)this).start();
- }
-
- private synchronized ScreenUpdaterEntry nextEntry() throws InterruptedException {
- while(true) {
- if (this.first == null) {
- ScreenUpdaterEntry entry = null;
- this.wait();
- } else {
- long delay = this.first.when - System.currentTimeMillis();
- if (delay <= 0L) {
- ScreenUpdaterEntry entry = this.first;
- this.first = this.first.next;
- return entry;
- }
-
- ScreenUpdaterEntry entry = null;
- this.wait(delay);
- }
- }
- }
-
- public void run() {
- SecurityManager.setScopePermission();
- ((Thread)this).setName("ScreenUpdater");
-
- try {
- while(true) {
- ((Thread)this).setPriority(4);
- ScreenUpdaterEntry entry = this.nextEntry();
- ((Thread)this).setPriority(entry.client.updatePriority());
-
- try {
- entry.client.updateClient(entry.arg);
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- ScreenUpdaterEntry var5 = null;
- }
- } catch (InterruptedException var4) {
- }
- }
-
- public void notify(UpdateClient client) {
- this.notify(client, 100L, (Object)null);
- }
-
- public synchronized void notify(UpdateClient client, long delay) {
- this.notify(client, delay, (Object)null);
- }
-
- public synchronized void notify(UpdateClient client, long delay, Object arg) {
- long when = System.currentTimeMillis() + delay;
- long nextwhen = this.first != null ? this.first.when : -1L;
- if (this.first != null) {
- if (this.first.client == client) {
- when = Math.min(this.first.when, when);
- this.first = this.first.next;
- } else {
- for(ScreenUpdaterEntry e = this.first; e.next != null; e = e.next) {
- if (e.next.client == client && e.next.arg == arg) {
- when = Math.min(e.next.when, when);
- e.next = e.next.next;
- break;
- }
- }
- }
- }
-
- if (this.first != null && this.first.when <= when) {
- ScreenUpdaterEntry e;
- for(e = this.first; e.next != null && e.next.when <= when; e = e.next) {
- }
-
- e.next = new ScreenUpdaterEntry(client, when, arg, e.next);
- } else {
- this.first = new ScreenUpdaterEntry(client, when, arg, this.first);
- }
-
- if (nextwhen != this.first.when) {
- super.notify();
- }
-
- }
- }
-