01: /**
02:    This program runs four threads that deposit and withdraw
03:    money from the same bank account. 
04: */
05: public class BankAccountThreadTester
06: {
07:    public static void main(String[] args)
08:    {
09:       BankAccount account = new BankAccount();
10:       final double AMOUNT = 100;
11:       final int REPETITIONS = 1000;
12: 
13:       DepositRunnable d1 = new DepositRunnable(
14:             account, AMOUNT, REPETITIONS);
15:       WithdrawRunnable w1 = new WithdrawRunnable(
16:             account, AMOUNT, REPETITIONS);
17:       DepositRunnable d2 = new DepositRunnable(
18:             account, AMOUNT, REPETITIONS);
19:       WithdrawRunnable w2 = new WithdrawRunnable(account, 
20:             AMOUNT, REPETITIONS);
21: 
22:       Thread t1 = new Thread(d1);
23:       Thread t2 = new Thread(w1);
24:       Thread t3 = new Thread(d2);
25:       Thread t4 = new Thread(w2);
26: 
27:       t1.start();
28:       t2.start();
29:       t3.start();
30:       t4.start();
31:    }
32: }
33: