IN JAVA OR C++ you will simulate a simple multithreading application with a “producer and consumer”   problem Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1. The user will run the program and will enter two numbers on the command line.Those numbers will be used for buffersize and counter limit.2. The main program will then create separate producer and consumer threads.3. The Producer thread generates a random number through a random number generator function, inserts it into the buffer, prints the number, and increment counter.4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it out, and increment counter.5. After the counter reaches its limit, both threads should be terminated and returned to the main.6. Main program terminates.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

 IN JAVA OR C++ you will simulate a simple multithreading application with a “producer and consumer”   problem

Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer 
space, not “buffersize – 1” as in the lecture note. This program should work as follows: 
1. The user will run the program and will enter two numbers on the command line.
Those numbers will be used for buffersize and counter limit.
2. The main program will then create separate producer and consumer threads.
3. The Producer thread generates a random number through a random number 
generator function, inserts it into the buffer, prints the number, and increment 
counter.
4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it 
out, and increment counter.
5. After the counter reaches its limit, both threads should be terminated and returned to 
the main.
6. Main program terminates.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Map
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,