Examlex

Solved

Assume Three Threads Share a BankAccount Object with Balance of Zero

question 54

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() ;
}


Definitions:

Marketing Strategy

A company's overall game plan for reaching prospective consumers and turning them into customers of their product or service.

CEO

The Chief Executive Officer, highest-ranking person in a company or organization, responsible for making major corporate decisions.

CMO

Chief Marketing Officer, a senior executive responsible for developing and overseeing marketing and advertising strategies.

Product Manager

A professional responsible for the strategy, roadmap, and feature definition for a product or product line.

Related Questions