subject

The pseudocode for a bank account supporting concurrent access. Assume that Lock is a valid locking class, although it is not in Java. Since Lock is not reentrant, the code below is broken. Assuming Lock is not reentrant, Please help me to provide a detailed example where the withdraw method would block forever. Refer to locks using the commented operation number. class BankAccount { private int balance = 0; private Lock lk = new Lock(); int getBalance() { lk. acquire(); // Operation 1 int ans = balance; lk. release(); // Operation 2 return ans; } void setBalance(int x) { lk. acquire(); // Operation 3 balance = x; lk. release(); // Operation 4 } void withdraw(int amount) { lk. acquire(); // Operation 5 int b = getBalance(); if (amount > b) { lk. release(); // Operation 6 throw new (); } setBalance(b - amount); lk. release(); // Operation 7 }}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:20
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. the program should output the average high, average low, and the highest and lowest temper- atures for the year. your program must consist of the following functions: a. function getdata: this function reads and stores data in the two- dimensional array. b. function averagehigh: this function calculates and returns the average high temperature for the year. c. function averagelow: this function calculates and returns the aver- age low temperature for the year. d. function indexhightemp: this function returns the index of the highest high temperature in the array. e. function indexlowtemp: this function retur
Answers: 3
question
Computers and Technology, 25.06.2019 01:00
Your computer will organize files into order. alphabetical chronological size no specific
Answers: 2
question
Computers and Technology, 25.06.2019 12:00
Jenny is the project manager and her company. she needs to break her current project into parts that her employees can work on. if jenny brings her project into as many small parts, but will lead to? a. increased quality control b. macro-management c. project disruption d. micro-management
Answers: 1
You know the right answer?
The pseudocode for a bank account supporting concurrent access. Assume that Lock is a valid locking...
Questions
question
Social Studies, 03.12.2021 01:00
question
Computers and Technology, 03.12.2021 01:00