Back to slide -- Keyboard shortcut: 'u'        next  ProducerConsumerTest.java - Producent klassen.Lecture 14 - slide 35 : 41
Program 1

class Producer extends Thread {
    private CubbyHole cubbyhole;
    private int number;

    public Producer(CubbyHole c, int number) {
        cubbyhole = c;
        this.number = number;
    }

    public void run() {
        for (int i = 0; i < 10; i++) {
            cubbyhole.put(i);
            try {
                sleep((int)(Math.random() * 100));
            } catch (InterruptedException e) { }
        }
    }
} // end Producer