The lock-based solution to the first part of the problem is: class Account: member balance : Integer member mutex : Lock method deposit(n : Integer) mutex.lock() balance ← balance + n mutex.unlock() method withdraw(n : Integer) deposit(−n) The second part of the problem is much more complicated.
Az első rész megoldása: class Account: member balance : Integer member mutex : Lock method deposit(n : Integer) mutex.lock() balance ← balance + n mutex.unlock() method withdraw(n : Integer) deposit(−n) A megoldás másik része sokkal nehezebb.