Multiple Choice
Assume three threads share a BankAccount object with balance of zero (0) , a ReentrantLock named myLock, and a condition object on myLock named lowBalanceCondition, as shown below. Thread one calls withdraw(30) , then thread two calls withdraw(20) and thread three calls deposit(45) . If the starting balance is 0, what is the balance after the three calls? public void deposit(int dollars)
{
MyLock.lock() ;
Int newBalance = balance + dollars;
System.out.println("depositing") ;
Balance = newBalance;
MyLock.unlock() ;
}
Public void withdraw(int dollars)
{
MyLock.lock() ;
While (balance < dollars)
{
LowBalanceCondition.await() ;
}
Int newBalance = balance - dollars;
System.out.println("withdrawing") ;
Balance = newBalance;
MyLock.unlock() ;
}
A) 0
B) 15 or 25
C) 45
D) -5
Correct Answer:

Verified
Correct Answer:
Verified
Q23: a(n. _ uses a small number of
Q34: _ occur(s) if the effect of multiple
Q42: When a sleeping thread is interrupted, an
Q47: For threads of equal priority, which is
Q48: Suppose that the class XYZ implements the
Q48: What should be done to get the
Q50: Which argument(s) present(s) the best case(s) for
Q52: Which method(s) are part of the Thread
Q55: Assume two threads share a BankAccount object
Q80: When is it a good idea to