public class Source extends Thread { private String[] name; private int[] height; private int[] weight; private int next; private QBuffer out; // constructor: initializes arrays, index, buffer pointer public Source (QBuffer b) { // the input parameter b is a pointer to an output queue name = new String[] {"Fred", "Jane", "Frank", "Jill", "Fran", "Jack"}; height = new int[] {66, 64, 73, 68, 63, 69}; weight = new int[] {160, 120, 200, 180, 125, 173}; out = b; // save reference to output buffer next = 0; } // get items from array data, send to out queue // send Go Away message after all data has been sent public void run() { while (next < name.length) { if (! out.isFull()) { Person p = new Person(name[next], height[next], weight[next++]); out.enqueue(p); } else { yield(); } } Person last = new Person("Go Away", 0, 0); while (out.isFull()) yield(); out.enqueue(last); System.out.println("Source is done"); } }