Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

After reading the webpage, modify the code BakerThreadTest. Modify the code as follows: The Baker should bake the pies randomly. Use a random number generator

After reading the webpage, modify the code BakerThreadTest.

Modify the code as follows:

The Baker should bake the pies randomly. Use a random number generator to choose whetherthe next pie baked is cherry or apple.After 4 apple pies are made the Baker will only make cherry. Also, after 4 cherry pies are made the Bakerwill only make apple. Your code shouldinclude the logic for this. Besidesthese restrictions the choice of what type of pie to make should be random.

Create a CherryEater that eatsonly cherry pies. Create a AppleEaterthat eats only apple pies. Both types ofeaters wait until 2 types of their favorite pie is made and then eat 2 pies ata time after which they wait until 2 more pies are finished. After each eater eats 4 pies they arefinished.

You will need two different synchronizationobjects one for cherry and one for apple, and two different sets of methodsfor adding to and eating pies.Alternatively, you can create two different Data classes one forcherry and one for apple.

Full java source code (not a screenshot) of each java file.

Screenshot of Eclipse showing output of program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago