Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 listb) have a consumer thread that handles removing items from a linked listc) 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 infinitelyg) 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 codethat 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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago