Avoiding Deadlocks
- How can we wait for the balance to grow?
- We can't simply call sleep inside withdraw method;
thread will block all other threads that want to use balanceChangeLock
- In particular, no other thread can successfully execute deposit
- Other threads will call deposit, but will be blocked until withdraw exits
- But withdraw doesn't exit until it has funds available
- DEADLOCK