edu.pdx.cs399J.net
Class ATM
java.lang.Object
edu.pdx.cs399J.net.ATM
- All Implemented Interfaces:
- Runnable
- Direct Known Subclasses:
- SynchronizedATM
public class ATM
- extends Object
- implements Runnable
This class demonstrates how concurrent access to a bank account
needs to be synchronized in order to guarantee the balance is
always correct.
|
Method Summary |
static void |
main(String[] args)
Create a couple of accounts and have them all perform the same
transactions, but in different orders. |
void |
run()
Perform each transaction on the account |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
out
protected static PrintStream out
name
protected String name
account
protected BankAccount account
transactions
protected int[] transactions
ATM
public ATM(String name,
BankAccount account,
int[] transactions)
run
public void run()
- Perform each transaction on the account
- Specified by:
run in interface Runnable
main
public static void main(String[] args)
- Create a couple of accounts and have them all perform the same
transactions, but in different orders.
Copyright © 2000-2009 Portland State University. All Rights Reserved.