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;
}
A) The calls were interleaved: thread one, thread two, thread one, thread two, …
B) The first call was to the deposit method.
C) The last call was to the withdraw method.
D) Each individual call to the deposit and withdraw methods ran to completion.
Correct Answer:

Verified
Correct Answer:
Verified
Q1: Assume two threads share a BankAccount object
Q5: Assume three threads share a BankAccount object
Q20: Under what circumstances will a call to
Q25: Suppose thread one is downloading a large
Q26: The sleep method is terminated with a(n)
Q42: When a sleeping thread is interrupted, an
Q48: What should be done to get the
Q66: The _ occurs when a thread that
Q69: The _ method is called by a
Q74: A GUI should be responsive to the