    001    package escjava.gui;
    002
    003    public class TaskQueue {
    004
    005        //@ non_null
    006        private java.util.LinkedList tasks = new java.util.LinkedList();
    007
    008        synchronized public void addTask(Object o) {
    009            tasks.addLast(o);
    010            notifyAll();
    011        }
    012
    013        synchronized public Object getTask() {
    014            while (tasks.isEmpty()) {
    015                try { wait(); } catch (Exception e) {}
    016            }
    017            return tasks.removeFirst();
    018        }
    019
    020        synchronized public void clear() {
    021            tasks.clear();
    022        }
    023    }