Examlex

Solved

Assume Three Threads Share a BankAccount Object with Balance of Zero

question 5

Multiple Choice

Assume three threads share a BankAccount object with balance of zero (0) , a ReentrantLock named myLock, and has 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 and after the waiting threads have had a chance to run?
Public void deposit(int dollars)
{
MyLock.lock() ;
Int newBalance = balance + dollars;
System.out.println("depositing") ;
Balance = newBalance;
LowBalanceCondition.signalAll() ;
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() ;
}


Definitions:

Reverse or Modify

Legal terms referring to a court's power to change or overturn a lower court's decision upon review.

Remand

The act of sending a case back to a lower court from a higher court for further action or reconsideration.

Venue

The specific location or jurisdiction where a legal trial or proceeding is to be held or where a contract is to be performed.

In Personam Jurisdiction

In personam jurisdiction refers to the power of a court to render a decision affecting the rights of the specific persons before the court.

Related Questions