// This class encapsulates a Producer. Each new instance of this class // creates a different thread which tries to nq into the queue // Currently queues random values generated by the Random class // If timeout expires, the Producer instance returns //package NexusII.util ; import java.util.Random ; public class Producer extends Thread { // If no time out is desired, timeout value is set to one. so the run method // knows which nq to call public Producer(MT_Bounded_Queue queue) { this.queue_ = queue ; this.iterations_ = new Integer(DEFAULT_ITERATIONS); this.time_out_ = -1 ; } // Include the name of the thread as a parameter public Producer(MT_Bounded_Queue queue, String name) { super(name); this.queue_ = queue ; this.iterations_ = new Integer(DEFAULT_ITERATIONS); this.time_out_ = -1 ; } // If the number of iterations are also included -- public Producer(MT_Bounded_Queue queue, String name, Integer iterations) { super(name); this.queue_ = queue ; iterations_ = iterations ; this.time_out_ = -1 ; } // Finally, if the timeout period is also included public Producer(MT_Bounded_Queue queue, String name, Integer iterations, long msec_timeout) { super(name); this.queue_ = queue ; iterations_ = iterations ; this.time_out_ = msec_timeout ; } // The hook method called by start() public void run() { // Initialize the random number generator Random rand = new Random(); for(int i=0;i