public class Account {
private UUID id;
private BigDecimal balance;
 
public UUID getId() {
return id;
}
}
 
public class MoneyTransferService {
(account1, account2)
(account2, account1)
 
public void transfer(Account from, Account to, BigDecimal amount) {
Account first;
Account second;
if (from.getId().compareTo(to.getId()) == 1) {
first = from;
second = to;
} else {
first = to;
second = from;
}
 
synchronized
}
 
}