Examlex

Solved

Assume Three Threads Share a BankAccount Object with a Balance

question 2

Multiple Choice

Assume three threads share a BankAccount object with a balance initially zero (0) , a ReentrantLock named myLock, and a condition object on myLock named insufficientFunds, as shown below.Thread one calls withdraw(30) , then thread two calls withdraw(20) and thread three calls deposit(45) .What is the balance after the three calls and after the waiting threads have had a chance to run? Assume three threads share a BankAccount object with a balance initially zero (0) , a ReentrantLock named myLock, and a condition object on myLock named insufficientFunds, as shown below.Thread one calls withdraw(30) , then thread two calls withdraw(20)  and thread three calls deposit(45) .What is the balance after the three calls and after the waiting threads have had a chance to run?    A) 0 B) 15 or 25 C) 45 D) -5


Definitions:

Organized

Having a structured and systematic arrangement; often refers to entities or groups that are systematically coordinated, such as labor unions.

Efficient

The ability to achieve maximum productivity with minimum wasted effort or expense, often related to processes, systems, or machines.

Continuous Replacement

A strategy that involves regularly updating and replacing resources, assets, or personnel to maintain efficiency and competitiveness.

Part-Time Employees

Workers who are employed for fewer hours than the full-time work schedule, typically resulting in fewer benefits and protections.

Related Questions