The Java Program: Kitchen1.java
1
2
3 public class Kitchen1 {
4
5
6 static MeasuringCup cup = new MeasuringCup();
7 static MixingBowl bowl = new MixingBowl();
8
9 public synchronized void makeCookies () {
10 cup.put (2, "flour");
11 bowl.put (cup);
12 bowl.mix ();
13
14 }
15
16 public synchronized void makeOmelette () {
17 bowl.put ("eggs");
18 bowl.mix ();
19 cup.put (bowl);
20
21 }
22
23
24 public static void main (String args[]) {
25 final Kitchen1 k = new Kitchen1 ();
26 class SwedishChef implements Runnable {
27 public void run () { k.makeCookies(); }
28 }
29 new Thread (new SwedishChef(), "Swedish Chef").start();
30 class JuliaChild implements Runnable {
31 public void run () { k.makeOmelette(); }
32 }
33 new Thread (new JuliaChild(), "Julia Child").start();
34 }
35 }