Question: 11. The code shown in Figure 3, can deadlock if bidirectional transfers happen at the same time, i.e. transfer from tank A to tank B

 11. The code shown in Figure 3, can deadlock if bidirectional

11. The code shown in Figure 3, can deadlock if bidirectional transfers happen at the same time, i.e. transfer from tank A to tank B happens at the same time (concurrent) that there is another transfer from tank B to tank A. [7 points] a. Explain why it will deadlock. [2 points] b. Rewrite the method transfer To so that it will not deadlock. [4 points] c. Explain why your solution in 11 b. is deadlock free. [1 point] public final class Water Tank { .. private int water TankId; // Unique Identifier public synchronized void fillTank(int noliters) {...} public synchronized void drainTank(int noliters) {...} public synchronized void transferTo(int noliters, Water Tank wtRight) { this.drainTank(noLiters); wtRight.fillTank(noLiters); } } Figure 3: WaterTank Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!