I see!
In a more realistic exercise the transactions should be implemented in a way that lock both accounts before making any movement.
Yes but with just mutexes, you may end up in a deadlock. For ex think of the case where A sends to B and B sends to A at the same time.
You have to be careful how you plan this. A way to do this would be using hierarchical mutex where you lock a higher layer mutex for the sender and a lower layer mutex for the receiver. A lower mutex should not be locked unless a higher layer mutex is locked as well.
There are many solutions to this that don't involve mutexes even.
Anonymous
Віктор
João
Suka
klimi
Crow
Alexandr
Ziky
dimazava
Roxifλsz 🇱🇹
Guillermo
Safwan
Michel
Ибраги́м
kunal