
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;

public class Thread5  {

  final int COUNTS = 20000;
  final int WORKERS = 20;
  private long _v[] = new long[COUNTS];
  private long _summe=0;   // Kontrollsumme


  // init der Daten
  public void init() {
    // _v[] = new long[ COUNTS ];
    for (int i=0; i<COUNTS; i++) {
      _v[i] = i+1;
      _summe += (i+1);
    } // for
  } // init;


  public void work() {
    CalcSumme Csumme;
    Thread t[];
     // Init
     // Summenklasse erzeugen
     // Thread erzeugen
     // Grenzen aufteilen
     // Thread starten
     // warten auf Beendigung

     // ???

    System.out.println("1. Ergebnis: "+_summe
             +"    2. Ergebnis: "+Csumme.getResult() );
  }





  private static void pause() {
    try {
      System.in.read();
    }
    catch (IOException e) {
    }
  }


   // MAIN
  public static void main(String[] args) {
    Thread5 m = new Thread5();
    m.work();
    pause();
  }


}


// Methode CalcSumme sammelt die Summen
class CalcSumme {
  long result = 0;

     // ???


} // CalcSumme



// Threadklasse zur Summation
class CalcAddiere implements Runnable {

    // lokale Variablen
  long [] _v;
  CalcSumme _Cs;
  int _id;
  int _i1;
  int _i2;

  public CalcAddiere (long[] v, CalcSumme Cs, int id, int i1, int i2) {
    _v = v;
    _Cs = Cs;
    _id = id;
    _i1 = i1;
    _i2 = i2;
    System.out.println("Konstruktor CalcAddiere" );
  }


   // Thread Methode, Summation
  public void run() {
    System.out.println("Starten der Summation"+ "  id:"+_id+"   i1:"+_i1+"   i2:"+_i2 );

    doSomeWork(200);
    // lokale Addition
     // ???
    System.out.println("Ende der Summation"+ "  id:"+_id);
  }  // run


  public void doSomeWork(double t) {
    long time;
    time = (long) (Math.random()*t);
    try {
      Thread.currentThread().sleep(time);
    }
    catch (InterruptedException e) {
    }
  } // doSomeWork1
  

} // CalcAddiere




