001    
002    /** 
003     * Finanz version C.
004     * Multi threaded application generates transactions using
005     * objects from KontoC and displays results.
006     * Uses Konto interface, non negative Konto and java.util.concurrent.
007     * @author Heinz Kredel. 
008     */ 
009    
010    public class FinanzC {
011    
012        public static void main(String[] args) {
013    
014          for (int i=0; i < 10; i++) {
015            Konto a = new KontoC(-10.0);
016            Konto b = new KontoC(300.0);
017    
018            Thread t1 = new Ueberweisung(a,b,10.0);
019            Thread t2 = new Ueberweisung(a,b,10.0);
020            Thread t3 = new Ueberweisung(a,b,10.0);
021            Thread t4 = new Ueberweisung(b,a,50.0);
022    
023            t1.start(); t2.start(); t3.start(); t4.start();
024    
025            System.out.println("Stand a = " + a.zeigeGeld() +
026                               " Stand b = " + b.zeigeGeld() );
027    
028            try {
029                t1.join(); t2.join(); t3.join(); t4.join();
030            } catch(InterruptedException e ) { }
031    
032            System.out.println("Endstand a = " + a.zeigeGeld() +
033                               " Endstand b = " + b.zeigeGeld() );
034          }
035        }
036    
037    }