import java.util.Random; public class MultiThreadBank { final Random _r = new Random(); final long INITIAL_FUNDS = 1000000; final int NUM_ACCOUNTS = 4; final long NUM_TRANSFERS = 1000; final int NUM_THREADS = 2; long[] _accounts = new long[NUM_ACCOUNTS]; Object[] _locks = new Object[NUM_ACCOUNTS]; class TransferRunnable implements Runnable { public void run() { for(int i=0; i "+to+": $"+amount); _accounts[from] -= amount; _accounts[to] += amount; } } } } } void run() { for(int i=0; i