Examlex

Solved

Assume Two Threads Share a BankAccount Object with Balance of Zero

question 74

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. If the balance after all thread calls is 0, which statement is definitely true? 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:

Credit

The provision of resources (such as money, goods, or services) by one party to another, with the expectation that the second party will repay the first party at a later date.

Pledge

A promise or agreement to do something, often backed by an assurance in the form of property or rights as a security for the fulfillment of an obligation.

UCC

The Uniform Commercial Code is a collection of legal guidelines that regulate business dealings across the United States.

Creditor

An individual or entity that is owed money or other forms of assets by a debtor.

Related Questions