Solved

Assume Two Threads Share a BankAccount Object with Balance of Zero

Question 46

Multiple Choice

Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides deposit and withdraw methods and has a ReentrantLock named myLock, as shown below.Note that only the deposit method uses the lock.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? Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides deposit and withdraw methods and has a ReentrantLock named myLock, as shown below.Note that only the deposit method uses the lock.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?    A) The balance could be zero or positive. B) The balance is zero. C) The balance could be zero or negative. D) The balance is positive.


A) The balance could be zero or positive.
B) The balance is zero.
C) The balance could be zero or negative.
D) The balance is positive.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions