Examlex

Solved

Assume Two Threads Share a BankAccount Object with Balance of Zero

question 24

Multiple Choice

Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides synchronized deposit and withdraw methods. Thread one deposits $10 ten times and, concurrently, thread two withdraws $10 ten times. Which statement regarding the balance after all thread calls is definitely true?
Public synchronized void deposit(int dollars)
{
Int newBalance = balance + dollars;
System.out.println("depositing") ;
Balance = newBalance;
}
Public synchronized void withdraw(int dollars)
{
Int newBalance = balance - dollars;
System.out.println("withdrawing") ;
Balance = newBalance;
}


Definitions:

Cost Change

Any variation, either an increase or decrease, in the total costs associated with production or operations.

Mixed Costs

Expenses that contain both fixed and variable components, changing in total with the level of activity.

Contribution Margin

The amount left from sales revenue after variable costs are subtracted, contributing to covering fixed costs and generating profit.

Merchandising Company

Businesses that buy finished goods and sell them at a profit without modifying the product, focusing on distribution rather than production.

Related Questions