Question: Java Problem : Consider a factory for cookies that has four production lines ( 1 . . 4 ) with different products. Each of the

Java Problem : Consider a factory for cookies that has four production lines (1..4) with different products.
Each of the four lines produces a certain flavor cookie. Each one has a certain ingredient in stock as shown below:
line1: flour, line2: sugar, leine3: butter, line4: eggs,
The recipe for each line needs to have all four ingredients.
Therefore, each line needs three more ingredients to produce the different types of cookies in addition to their stock ingredient.
As an example, line1 has flour but it needs the ingredients: sugar, butter, and eggs. For line2 that needs to get flour, butter and eggs. The same goes for line 3 and 4.
The central line of the factory can provide randomly these ingredients as needed and notifies the line who needs these ingredients. When the line gets the ingredients produces the cookies and wait for the next ingredients to get from the central line.
Prepare a program that simulates this system using threads (semaphores).

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 Programming Questions!