Write solution to solve the currently very un-pccigarette


Problem 2: (JAVA)

Write solution to solve the currently very un-PC"cigarette smokers problem" in java using Java threads, and monitors (using the "synchronized" keyword) (If it bothers your PC sensibilities, think of it at the Pot-smokers problem and then it is all proper again.

The cigarette smokers problem
Consider a simulation with three smoker threads and one agent thread. Each smoker continuously makes a cigarette and smokes it. But to make a cigarette, a smoker needs three ingredients: tobacco, paper, and matches. One of the smoker threads has only paper, another has only tobacco, and the third has only matches. The agent thread has an infinite supply of all three materials. The three smoker threads are initially blocked. The agent places two randomly chosen (different) ingredients on the table and unblocks the one smoker who has the remaining ingredient. The agent then blocks. The unblocked smoker removes the two ingredients from the table, makes a cigarette, and smokes it for a random amount of time, unblocking the agent on completion of smoking the cigarette. The agent then puts out another random two of the three ingredients, and the cycle repeats.

In addition to the solutions to your programs above, you need to write a readme.txt it should contain
  • Well commented program. 
  • how to compile your program (including the actual compile command) and how to run it (including command line arguments, if any)
  • A description of your solution to these two problems, including what you did to solve the problem, and why you did it that way
  • A description of what problems still exist, what doesn't quite work right and so on.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write solution to solve the currently very un-pccigarette
Reference No:- TGS0660480

Expected delivery within 24 Hours