001 //package edu.unima.ky.parallel; 002 003 /** 004 * Finanz version A. 005 * Multi threaded application generates transactions using 006 * objects from KontoA and displays results. 007 * Uses synchronized Konto. 008 * @author Heinz Kredel. 009 */ 010 011 public class FinanzA { 012 013 /** 014 * @param args 015 */ 016 public static void main(String[] args) { 017 018 for (int i=0; i < 10; i++) { 019 KontoA a = new KontoA(0.0); 020 KontoA b = new KontoA(2000); 021 022 Thread t1 = new UeberweisungA(a,b,10.0); // a is the accont to get amount from. 023 Thread t2 = new UeberweisungA(a,b,10.0); // b is account to add amount to. 024 // 10.0 is the amount to transfer. 025 Thread t3 = new UeberweisungA(a,b,10.0); 026 Thread t4 = new UeberweisungA(b,a,30.0); 027 028 t1.start(); t2.start(); t3.start(); t4.start(); 029 030 System.out.println("Stand a = " + a.zeigeGeld() + 031 " Stand b = " + b.zeigeGeld() ); 032 033 try { 034 t1.join(); t2.join(); t3.join(); t4.join(); 035 } catch(InterruptedException e ) { } 036 037 System.out.println("Endstand a = " + a.zeigeGeld() + 038 " Endstand b = " + b.zeigeGeld() ); 039 } 040 } 041 042 }