Question: Problem: Consider a system with three smoker processes and one agent process (multiple threads problem). Each smoker continuously rolls a cigarette and then smokes it.
Problem: Consider a system with three smoker processes and one agent process (multiple threads problem). Each smoker continuously rolls a cigarette and then smokes it. But to roll and smoke a cigarette, the smoker needs three ingredients: tobacco, paper, and matches. One of the smoker processes has paper, another has tobacco, and the third has matches. The agent has an infinite supply of all three materials. Every time the agent places two of the ingredients on the table The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredients, and the cycle repeats. Write a program to synchronize the agent and the smokers using Java synchronization. Requirements: . One class for Smoker that you should create 3 threads, and .You should show that your solution works by having each . Print out the result for some long period and analysis your Finally you need to analysis to see if deadlock occurs? If one class for agent that you have one thread. smoker thread smoke three cigarettes at least. result. yes, under what condition
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
