edu.pdx.cs399J.net
Class ATM

java.lang.Object
  extended by 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.


Field Summary
protected  BankAccount account
           
protected  String name
           
protected static PrintStream out
           
protected  int[] transactions
           
 
Constructor Summary
ATM(String name, BankAccount account, int[] transactions)
           
 
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
 

Field Detail

out

protected static PrintStream out

name

protected String name

account

protected BankAccount account

transactions

protected int[] transactions
Constructor Detail

ATM

public ATM(String name,
           BankAccount account,
           int[] transactions)
Method Detail

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.