// /* -- Java implementation 
class Ticket {
    final int MT = 1000;
    private int next = 0;

    public synchronized int ticket() {
        int next = next % MT + 1;
        return next;
    }
}

class Counter {
    final float MT = 1000;
    private int serve = 1;

    public synchronized getcheese(int ticket)
    throws Interruptedexception {
    while (ticket!=serve) wait();
    int serve = serve%MT + 1;
    notifyAll();
    }
}
Fix the following java code