WithdrawThread - public void run try for(int i = 1 i<= REPETITIONS&&!isInterrupted i account.withdraw(amount sleep(DELAY catch( exception

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** A withdraw thread makes periodic withdrawals from a bank account. */ class WithdrawThread extends Thread { /** 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;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public void run() { try { for (int i = 1; i <= REPETITIONS && !isInterrupted(); i++) { account.withdraw(amount); sleep(DELAY); } } catch (InterruptedException exception) { } } private BankAccount account; private double amount; private static final int REPETITIONS = 1000; private static final int DELAY = 0; }...
View Full Document

This note was uploaded on 09/29/2010 for the course COMPUTER S cps615 taught by Professor Pro during the Spring '10 term at Randolph College.

Ask a homework question - tutors are online