Question
Problem Description Homer Simpson has been twice cloned, so now the world must deal with three Homers with insatiable appetites for donuts. In this problem
Problem Description Homer Simpson has been twice cloned, so now the world must deal with three Homers with insatiable appetites for donuts. In this problem there are four tasks: three Homers (not quite identical) and a Donut Chef. Each of the Homer tasks will make a donut and eat it. The items necessary to build a donut are: the cooked donut shell (the dough shaped for a filled donut), filling, and sprinkles. Each Homer possesses one of the three items in an infinite quantity (IE. one has donut shells, another has filling, and a third has sprinkles). The Donut Chef has an infinite supply of all three items necessary to build a donut. At random, the Donut Chef places two different (of the three necessary) items on a table. The Homer that has the third item, acquires the contents of the table, notifies the Chef, then builds the donut and consumes it (a Homer must have all three items to build a donut.) Each Homer may take a variable time to build and consume their masterpiece. After the notification, the Donut Chef then places two different (of the three necessary) items (at random) on the table, and the cycle continues. Your job is to implement a solution that synchronizes the Homers and the Donut Chef in a Java application (called Donut) using semaphores such that a deadlock or indefinite postponement will not occur. Your solution to the Homer Simpson Problem must use the semaphore primitives available in Java to synchronize the Homers and Chef. The Homers and Chef code must be based on the Java semaphore implementation and must not use any other synchronization technique. In your implementation, each Homer, as well as the Chef, are required to run as separate threads. The Chef must use the Random class from java.util to create a seeded random number sequence. Your program must accept the seed value as an argument on the command line (java Donut seedvalue.) Include print statements that 2 show the state of your system such that the events can be traced. Use indentation, blank lines and specific labels to show your output in a clear and concise manner. The finished assignment must include the following (in a ZIP file that extracts as a single directory do not create jar files or packages): A detailed methodology A detailed design The Java Donut Implementation o The Java Source Code o The Class files o The system must compile using the command: javac *.java o The system must run using the command: java Donut seedvalue, where seedvalue is an integer of type long.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started