Question
java Ahmad and Mohammad are friends and they want to enjoy eating buttered bread sandwich prepared by them. They need bread and butter to prepare
java
Ahmad and Mohammad are friends and they want to enjoy eating buttered bread sandwich prepared by them. They need bread and butter to prepare sandwich. Bread and butter are provided to them by keeping them on a table.
For the aforementioned scenario, develop a program that creates Ahmad and Mohammad as anonymous threads and check if they can prepare sandwich and enjoy eating it for the following conditions.
Ahmad and Mohammad are equally hungry and equally competitive. Both of them have to collect the bread and the butter one at time. Ahmad has in mind to collect (lock) bread first and then collect (lock) butter. Mohammad has in mind to collect (lock) butter first and then collect (lock) bread. Each person needs at least a second to collect the second item after collecting the first item. (Item: bread or butter.). Check if Ahmad and Mohammad are able to prepare sandwich and enjoy it.
Ahmad and Mohammad agree on the condition that they have to always collect bread first and then butter to prepare sandwich.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started