Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We have an implementation of Dinning Philosophers in Java. It includes DiningPhilosophers.java that creates and starts threads, PhilosopherThread.java that starts a thread for each philosopher,

image text in transcribedimage text in transcribed

We have an implementation of Dinning Philosophers in Java. It includes DiningPhilosophers.java that creates and starts threads, PhilosopherThread.java that starts a thread for each philosopher, and PhilosopherTable java that includes methods pickup() putdown() and test() that look like the following. Fill in the missing code (indicated by - blanki-) public -blank2- void putdown(int i) { setState(i, -blank3-); test(right(i)); testC-blank4-); } public synchronized void pickup(int i) throws InterruptedException { setStateci, State. HUNGRY); -blank1-3 while (state[i] != State. EATING) { this.wait(); // Recheck condition in loop, // since we might have been notified // when we were still hun } private synchronized void test(int i) { if (state[left(i)] != State.EATING && blank5- !=-blank6- && state[i] - State. HUNGRY) } setState(i, -blank7-); // Wake up all waiting threads this.notifyAllo; } } -blank1- [ Choose ] -blank1- -blank2- [Choose ] synchronized left(0) State.EATING State.THINKING state[right] test(i) State.HUNGRY -blank3- -blank4- [Choose ] -blank5- [ Choose -blank6- [Choose ] 4 -blank7- [Choose ]

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Coping with competitive pressure and sport performance anxiety

Answered: 1 week ago

Question

What is management growth? What are its factors

Answered: 1 week ago

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago