Write a program to simulate the behavior of the philosophers

Assignment Help JAVA Programming
Reference no: EM13332141

Dining Philosophers Problem

Imagine n philosophers who spend their lives just thinking and feasting. They sit around a circular table, each in front of his own plate. However, there are only n chopsticks available. Each philosopher thinks for some time. When he gets hungry, he tries to pick up the two chopsticks that are closest to him. If both chopsticks are available, he takes them and eats for a while. After a philosopher finishes eating, he puts down the chopsticks and again starts to think.

To not disrupt each others thoughts, philosophers do not communicate with each other and try to chew silently.

Write a program to simulate the behavior of the philosophers, where each philosopher is a thread and the chopsticks are shared objects.

Notice:

• You must prevent a situation where two philosophers hold the same chop-stick at the same time.
• It must never be the case that a philosopher hold one chopstick and is stuck waiting for another to get the second chopstick, i.e. your program should be deadlock free.
• Extend your program in such a way that philosophers never starve.

Details for submission:

• Submit an executable .jar file named philosopher.jar which includes the source files.
• The program should take as parameter the number of philosophers. Calling java -jar philosopher.jar 7 shall simulate seven philosophers sitting around the table.
• Also, in a text file, provide a user documentation to outline how your program can be compiled and executed.

Reference no: EM13332141

Questions Cloud

What is the take-off speed of the jet : The thrust produced by a single jet engine, m=7300kg, creates a force F=73000N. It takes the jet a distance of d=0.84km to take off. What is the take-off speed of the jet
Current global economy requires intricacy : The current global economy requires intricacy in thinking through business issues. It also requires cultural understanding and negotiation skills as well as innovative and sustainable ideas to solve problems. The problems and possibilities that you w..
What is the radius of the concave surface : A planoconcave lens (n = 1.52) has a focal length of -24.6cm. What is the radius of the concave surface
Evaluate pcu at the equivalence point in the titration : Calculate pCu at the equivalence point in the titration of 20.0 mL of 0.0161 M CuSO4 with 0.0100 M EDTA at pH 8.00.
Write a program to simulate the behavior of the philosophers : Write a program to simulate the behavior of the philosophers, where each philosopher is a thread and the chopsticks are shared objects.
What is the size of the equal installments : A loan of $7000 taken out two years ago is to be repaid in three equal installments due now, two years from now, and three years from now respectively. What is the size of the equal installments if interest on the debt is 12% compounded monthly?
The topic is managerial accounting : The topic is managerial accounting / cost accounting.
How to evaluate the molar concentration of mg2+ : A 200.0-mL sample of the same tap water required 47.86 mL of the standard EDTA for titration at pH 10 using calmagite indicator. Calculate the molar concentration of Mg2+ in the tap water.
An accrual basis taxpayer : For each of the following independent situations, state which concept(s) is (are) responsible for the treatment and EXPLAIN how each concept is applied.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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