previous | start | next

Answers

  1. Two, one for each bank account object. Each lock protects a separate balance field.
  2. When a thread calls deposit, it continues to own the lock, and any other thread trying to deposit or withdraw money in the same bank account is blocked forever.


previous | start | next