Java: Setting up queue objects and manipulating their sizes

TJN23

Golden Member
May 4, 2002
1,670
0
0
We've been asked to instantiate Producer and Consumer Queues in Java. The producer "produces" string objects and puts them in the queue and the consumer "consumes", or prints out the string objects within the queue. The entire program uses 4 files:

-Queue.java creates a new Queue with methods getObject and putObject
-QueueConsumer.java creates the consumer queue
-QueueProducer.java creates the producer queue
-QueueMain.java drives everything, creating the consumer and producer threads and starts them up


We need to do 2 runs of the program: one in which the queue size is 10 and one in which the queue size is 200. Describe and explain the output that you see in each case.


The output is pretty much the same. The first will print out 10 strings while the second will print out 200 strings. It's just what goes on inside the queue that is different, but that isn't visibly demonstrated in the output of the program.

 

TJN23

Golden Member
May 4, 2002
1,670
0
0
Sorry for being unclear - what we had to do was do two runs of the program. One in which the queue size is 10. And one in which the queue size is 200. Then to describe and explain the output that you see in each case.

It's just I don't see how they would be any different?
 

AgentEL

Golden Member
Jun 25, 2001
1,327
0
0
Well, looking at your code quickly:
1. Your comment on the producer does not match what's happening. It's not putting 100 objects, it's only putting 10.
2. In your OP, you stated that one prints out 10 strings, the other 200. But, you are only changing the size of the queue, not how many strings are being printed.

Have you tried running the program yet?