All pastes #330296 Raw Edit

Miscellany

public java v1 · immutable
#330296 ·published 2007-01-27 20:04 UTC
rendered paste body
    public void run() {        while (!allDoneYet) {            if (!line.isEmpty()) {                Customer c = line.dequeue();                System.out.println("Processing cust...");                if (allDoneYet = c.process())                    notifyAll();            }            else                try {                    System.out.println("Thread waiting...");                    this.wait();                } catch (InterruptedException e) {                    e.printStackTrace();                }        }    }There is a line of customers, and when there are customers in the line, the cashiers pull them off and process them. When the line is empty, but customers are still in the 'store', the cashiers wait for customers to hit the line (the line handling class is supposed to notifyAll when a customer gets in line). If process returns "true", the last customer has been processed, and any waiting Cashiers will wake up and see that all the customers are gone and then terminate. How can I get this notifyAll to work?