Solve the currently very un-pc cigarette smokers problem

Assignment Help JAVA Programming
Reference no: EM13321809

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.

Reference no: EM13321809

Questions Cloud

What changes in society helped starbucks become successful : What advantages does McDonald's have in competing with Starbucks for coffee sales? What changes in society helped Starbucks become successful? What strategic factors account for Starbuck's long-term success in building brand equity? What recommendati..
Staff development programs to their curriculum : What measures can schools take to align their staff development programs to their curriculum? Provide a rationale for the measures suggested.
Community hospital uses a job-order costing system : Southwest Community Hospital uses a job-order costing system to track charges for each patient. The following charges relate to Candice O'Dea, who had laparoscopic knee surgery:
How to compile your 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..
Solve the currently very un-pc cigarette smokers problem : 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 pr..
Personal pollution-water pollution-air-noise-heat pollution : Remember that after you stand up from bed in the morning almost every activity of your day is going to produce some kind of pollution. Personal pollution could include: water pollution, air pollution, noise pollution, heat pollution, solid waste poll..
Null and entity subtypes : Describe the relationship between columns that can be null and entity subtypes. Under what circumstances would these columns lead to more than one entity subtype?
Delegation is a key role for all health professionals : Delegation is a key role for all health professionals. What are three factors to consider when delegating to unlicensed personnel in the health care setting?
What corporate social responsibilities : Use the five-forces framework to explain why the US smokeless tobacco industry is so profitable (as indicated by the profitability of its dominant firm). What corporate social responsibilities, if any, should the industry undertake?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Display the values that were typed in to the form

This assignment will focus on creating Java Server Pages (JSP) and deploying them onto a Java Servlet Container.

  Write a class that reads a file

In java, write a class that reads a file and outputs a list of the unique words in the file and the number of times each unique word occurs.Hint: use a HashMap with keys being the words and values being integer counts associated with the words.

  Determine the visual resolution of resulting image

Drawing in 8.5 by 11 inch sheet is digitized by means of 300 dpi (dots per inch) scanner. Determine the visual resolution of resulting image (number of dots in each dimension)?

  What are bufferedinput/outputstreams

What are BufferedInput/OutputStreams and why are they used? Write some Java code to illustrate how to create a BufferedInputStream.

  Write a java program that declares an array alpha of 50

Write a Java program that declares an array alpha of 50 elements of type double. Initialize the array so that the first 25 elements are equal to the square of the index variable, and the last 25 elements are equal to three times the index variable. O..

  When the user presses a button

When the user presses a button, get the text from text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let's call this largest word X for now. In response, create a question based on the length ..

  Display random numbers to simulate rolling a die

1. Display random numbers to simulate rolling a die2. Create a java program that simulate a casino game. (rollin a die)

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

  Pass in the number of gallons on board

public float usefulLoad() // this is the grossWeight - emptyWeight public float usefulLoadWithFuel( in gallons ) // this is the useful load - gallons x 6. The programmer user will pass in the number of gallons on board.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  Display student details and classes in applet

Display student details and classes they have enrolled in Applet. The Applet should have following features. Update and View.

  A class is a blueprint for an object

A class is a blueprint for an object. A class may have a default constructor, a constructor with arguments, accessor methods, mutator methods, public fields, and private fields.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd