import java.util.*;

public class ThreadsAndAccounts {
    public static void main (String[] args) throws Exception {
        BankAccount F = new BankAccount("Fiji", 1000);
        BankAccount J = new BankAccount("Jamaica", 1000);

		System.out.println("\r\nSTART: "+F.Amount+" + "+J.Amount+" = "+(F.Amount+J.Amount)+"\r\n");
	    
		List<AccountThread> threads = new ArrayList<AccountThread>();
		
        for (int i = 1; i <= 2; i++) {
            threads.add(new AccountThread("FJ"+i, F, J));
            threads.add(new AccountThread("JF"+i, J, F));
        }

		for (AccountThread t : threads) {
		    t.start();
		}
		
		for (AccountThread t : threads) {
		    t.join();
		}
		
		System.out.println("\r\nSTOP:  "+F.Amount+" + "+J.Amount+" = "+(F.Amount+J.Amount)+"\r\n");

        System.out.println("<enter> to exit");
        System.in.read();
    }
}
