/**
   A withdraw thread makes periodic withdrawals from a bank account.
*/
class WithdrawThread extends Thread
{

   private BankAccount account;
   private double amount;

   private static final int REPETITIONS = 3;

   /**
      Constructs a withdraw thread.
      @param anAccount the account from which to withdraw money
      @anAmount the amount to withdraw in each repetition
   */
   public WithdrawThread(BankAccount anAccount, double anAmount)
   {
      account = anAccount;
      amount = anAmount;
   }

   public void run()
   {
      try
      {
         for (int i = 1; i <= REPETITIONS; i++)
         {
            account.withdraw(amount);
            sleep((int)(Math.random()*100 + 1));         
         }
      }
      catch (InterruptedException exception) {
}
   }
}