You are given a class called SavingsAccount. It has:
- A
longfield calledtotal. - A
depositmethod that adds to thetotal. - A
withdrawmethod that subtracts the given amount from thetotal. It returnstrueif the operation is valid and successful andfalseotherwise.
The class should work with multiple threads. If multiple threads are operating
on the same instance of SavingsAccount, the total must have the correct
value once all the thread operations are completed.
class SavingsAccount {
private long total = 0;
public boolean withdraw(long amount) {
}
public void deposit(long amount) {
}
public long getTotal() {
return total;
}
}