In the classic problem of transferring money from one bank account to another, the accepted solution (I believe) is to associate a mutex with each bank account, then lock both b
There's nothing wrong with having the money "in flight" for a while. Make it like so:
Account src, dst; dst.deposit(src.withdraw(400));
Now just make each individual method thread-safe, e.g.
int Account::withdraw(int n) { std::lock_guard _(m_); balance -= n; return n; }