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:

Narcissism

Narcissism is characterized by a grandiose sense of self-importance, a constant need for admiration, and a lack of empathy for others.

Cultural Differences

Variations in the norms, values, beliefs, and practices among people from different backgrounds or communities.

Subjectivity

The quality of being based on or influenced by personal feelings, tastes, or opinions rather than external facts.

Subordinate Satisfaction

The level of contentment, motivation, and engagement experienced by employees towards their work and the workplace hierarchy.

Related Questions