ICUNotifier.java 2.67 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.agl.impl;

import java.util.EventListener;
import java.util.LinkedList;
import java.util.List;

public abstract class ICUNotifier {
    private final Object notifyLock = new Object();
    private NotifyThread notifyThread;
    private List listeners;

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void notifyChanged() {
        if (this.listeners != null) {
            Object object = this.notifyLock;
            synchronized (object) {
                if (this.listeners != null) {
                    if (this.notifyThread == null) {
                        this.notifyThread = new NotifyThread(this);
                        this.notifyThread.setDaemon(true);
                        this.notifyThread.start();
                    }
                    this.notifyThread.queue(this.listeners.toArray());
                }
            }
        }
    }

    protected abstract void notifyListener(EventListener var1);

    private static class NotifyThread
    extends Thread {
        private final ICUNotifier notifier;
        private final List queue = new LinkedList();

        NotifyThread(ICUNotifier notifier) {
            this.notifier = notifier;
        }

        /*
         * WARNING - Removed try catching itself - possible behaviour change.
         */
        public void queue(Object[] list) {
            NotifyThread notifyThread = this;
            synchronized (notifyThread) {
                this.queue.add(list);
                this.notify();
            }
        }

        /*
         * WARNING - Removed try catching itself - possible behaviour change.
         */
        public void run() {
            do {
                try {
                    block6 : do {
                        Object[] list;
                        NotifyThread notifyThread = this;
                        synchronized (notifyThread) {
                            while (this.queue.isEmpty()) {
                                this.wait();
                            }
                            list = (Object[])this.queue.remove(0);
                        }
                        int i = 0;
                        do {
                            if (i >= list.length) continue block6;
                            this.notifier.notifyListener((EventListener)list[i]);
                            ++i;
                        } while (true);
                        break;
                    } while (true);
                }
                catch (InterruptedException e) {
                    continue;
                }
                break;
            } while (true);
        }
    }

}