Examlex

Solved

Assume Two Threads Share a BankAccount Object with Balance of Zero

question 1

Multiple Choice

Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides deposit and withdraw methods as shown below. Thread one deposits $10 ten times and, concurrently, thread two withdraws $10 ten times. Suppose a race condition occurs, and the race is finished first by thread one. What would you expect balance to be after all thread calls?
Public void deposit(int dollars)
{
Int newBalance = balance + dollars;
System.out.println("depositing") ;
Balance = newBalance;
}
Public void withdraw(int dollars)
{
Int newBalance = balance - dollars;
System.out.println("withdrawing") ;
Balance = newBalance;
}


Definitions:

First Stage Cost Objects

In activity-based costing, initial categories where costs are collected before being assigned to final cost objects based on their use of activities.

Cost Objects

Items or activities for which costs are measured and assigned, such as products, services, projects, or departments.

Departmental Overhead Rate Method

A cost accounting technique that allocates overhead expenses to specific departments based on varying rates, often used to more accurately reflect the costs incurred by each department.

Related Questions