diff options
Diffstat (limited to 'java/apps/NexusII/src/Producer.java')
-rw-r--r-- | java/apps/NexusII/src/Producer.java | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/java/apps/NexusII/src/Producer.java b/java/apps/NexusII/src/Producer.java deleted file mode 100644 index 4153f7d79df..00000000000 --- a/java/apps/NexusII/src/Producer.java +++ /dev/null @@ -1,87 +0,0 @@ -// 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<iterations_.intValue();i++) - { - int err = 0 ; - // Get the next random value for insertion into queue - Integer new_item = new Integer(rand.nextInt()) ; - - // Doesnt make sense to have a negative timeout -- default - if(time_out_ < 0) - queue_.nq(new_item); - else - err = queue_.nq(new_item,time_out_); - - // If timedout stop this thread - if(err == -1) - { - System.out.println(getName() + ": Timed Out \n"); - return ; - } - - System.out.println(getName() + ": enqueued " + new_item.intValue()); - } - - } - -private static final int DEFAULT_ITERATIONS = 1 ; -protected MT_Bounded_Queue queue_ ; -private Integer iterations_ ; -private long time_out_ ; -} - - |