public void transfer(int from, int to, double amount) {
synchronized (accounts) {//double[] accounts - массив счетов в банке
if (accounts[from] < amount) return;
accounts[from] -= amount;
accounts[to] += amount;
}
}
synchornize(accounts[Math.min(from, to)])
{
synchorize(accounts[Math.max(from, to)])
{
}
}