|
@@ -23,6 +23,19 @@ public class MonkeyTypewriter {
|
23
|
23
|
// Do all of the Monkey / Thread building here
|
24
|
24
|
// For each Copier(one safe and one unsafe), create and start 5 monkeys copying the introduction to
|
25
|
25
|
// A Tale Of Two Cities.
|
|
26
|
+ UnsafeCopier dangerWillRobinson = new UnsafeCopier(introduction);
|
|
27
|
+ new Thread(dangerWillRobinson).start();
|
|
28
|
+ new Thread(dangerWillRobinson).start();
|
|
29
|
+ new Thread(dangerWillRobinson).start();
|
|
30
|
+ new Thread(dangerWillRobinson).start();
|
|
31
|
+ new Thread(dangerWillRobinson).start();
|
|
32
|
+
|
|
33
|
+ SafeCopier safetyFirst = new SafeCopier(introduction);
|
|
34
|
+ new Thread(safetyFirst).start();
|
|
35
|
+ new Thread(safetyFirst).start();
|
|
36
|
+ new Thread(safetyFirst).start();
|
|
37
|
+ new Thread(safetyFirst).start();
|
|
38
|
+ new Thread(safetyFirst).start();
|
26
|
39
|
|
27
|
40
|
|
28
|
41
|
// This wait is here because main is still a thread and we want the main method to print the finished copies
|
|
@@ -34,5 +47,9 @@ public class MonkeyTypewriter {
|
34
|
47
|
}
|
35
|
48
|
|
36
|
49
|
// Print out the copied versions here.
|
|
50
|
+ System.out.println("Unsafe Copier: ");
|
|
51
|
+ System.out.println(dangerWillRobinson.copied);
|
|
52
|
+ System.out.println("Safe Copier: ");
|
|
53
|
+ System.out.println(safetyFirst.copied);
|
37
|
54
|
}
|
38
|
55
|
}
|