\begin{slide}{Shop-Simulation}

Ein Angestellter (clerk) verkauft Brötchen an Kunden (customer):

\begin{verbatim}
public class Customer implements Runnable { ...
  public void run() {
    for (int i = 0; i<items; i++) {
      int x = clerk.get();
} } }
public class Clerk { ...
  private int current = 0;
  public int get() {
    int result = current; current++; 
    return result;
} }
\end{verbatim}
jedes Brötchen soll genau einmal verkauft werden
  
\end{slide}

\begin{slide}{Shop-Simulation (II)}
\begin{verbatim}
public static void main(String[] args) {
  Clerk bäcker = new Clerk ();
  for (int i=0; i<3; i++) {
    Customer c = new Customer
      (Integer.toString(i), bäcker, 10);
    new Thread(c).start();
} }
public static void abwarten() {
  int d = (int) Math.random () * 1000;
  Thread.sleep(d);
}
\end{verbatim}

\end{slide}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
