/**
 * A producer puts the integers 1, ..., ITERATION in the buffer.
 *
 * @version     1.1    January 25, 2000
 * @author      Franck van Breugel
 * @see Buffer
 */
public class Producer extends Thread {
    private Buffer buffer; // the buffer where this producer puts its elements

    /**
     * Constructs a producer which put elements in the specified buffer.
     * @param buffer The buffer where this producer puts its elements.
     */
    public Producer(Buffer buffer) {
        this.buffer = buffer;
    }

    /** Number of elements to be put in the buffer. */
    private static final int ITERATION = 20;

    /** Puts the integers 1, ..., ITERATION in the buffer. */
    public void run() {
        for (int i = 0; i < ITERATION; i++) {
            buffer.put(new Integer(i));
        }
    }
}