Question: Q 5 ) For the next problem, please use either Java, C , or C + + . If you wish to use a different

Q5) For the next problem, please use either Java, C, or C++. If you wish to use a different
language you must receive approval before submitting your assignment. You must write the
code yourself.
Write a program that adds and removes random integers between 1 and 1854 to a singularly
linked list using producer and consumer threads. You should include the source code that you
have written in a separate file along with your submission.
Your code should do the following:
a) have a producer thread that handles adding items to a linked list
b) have a consumer thread that handles removing items from a linked list
c) a class that contains a and initializes a linked list. The linked list should be of the size of the
last 3 digits of your student ID, which should be hard coded.
d) a main class that should call both the producer and consumer threads (assume they will run
forever)
e) make sure your code handles the cases where the linked list is full (producer can't add to the
linked list) and when the linked list is empty (consumer can't pull from the linked list)
Hint: it is recommended that you write some helper functions to traverse the linked list, check if it's full, and check if it's empty.
f) Run your code and include screenshots of your code running. For the first screenshot just
show your code working this version would just run infinitely
g) Modify your code so that you purposefully hit the case where the linked list is full and your
producer runs out of room to produce (and the helper function throws a message somehow to
inform that the case has been hit). Take a screenshot of this case as well as provide the code
that you did to produce this change.
h) Modify your code again to hit the case where the consumer runs out of things to consume
(and the helper function throws a message somehow to inform that the case has been hit).Take
a screenshot of this case as well as provide the code that you did to produce this change.
Note: This means you should include a minimum of 3 screenshots, plus provide the original
code, and both code changes for steps g and h you made to hit the full and empty cases
Please make sure to submit the text file with your answers to the theory questions as a
.docx, your source code for the code section (you might also want to include some
clarification within your text document), and the screenshots to the CMS in order to
receive full marks. Do NOTzip your files when submitting them to the CMS.
 Q5) For the next problem, please use either Java, C, or

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!