/**
 * A consumer gets ITERATION elements from the buffer.
 *
 * @version     1.1    January 25, 2000
 * @author      Franck van Breugel
 * @see Buffer
 */
public class Consumer extends Thread {
    private Buffer buffer; // the buffer from where this consumer gets its elements

    /**
     * Constructs a consumer which gets elements from the specified buffer.
     * @param buffer The buffer from where this consumer gets its elements.
     */
    public Consumer(Buffer buffer) {
        this.buffer = buffer;
    }

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

    /** Gets ITERATION integers from the buffer and prints them. */
    public void run() {
        for (int i = 0; i < ITERATION; i++) {
            System.out.println((Integer) buffer.get());
        }
    }
}