diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-25 22:18:58 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-25 22:18:58 +0000 |
commit | 7a5fe8ce23ac50450b804cf0183c773565ae7cef (patch) | |
tree | 220a38a6627619d1386897d42757a140b9de448f /java/apps/NexusII/src/Producer.java | |
parent | 87b0987cad99cf45cd5d9e03cd1cefbaaec4ef2a (diff) | |
download | ATCD-ACE-4_4.tar.gz |
This commit was manufactured by cvs2svn to create branch 'ACE-4_4'.ACE-4_4
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_ ; -} - - |