|
@@ -23,7 +23,15 @@ 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 unsafe = new UnsafeCopier(introduction);
|
|
27
|
+ for (int i=5; i>0; i--) {
|
|
28
|
+ new Thread(unsafe).start();
|
|
29
|
+ }
|
26
|
30
|
|
|
31
|
+ SafeCopier safe = new SafeCopier(introduction);
|
|
32
|
+ for (int i=5; i>0; i--) {
|
|
33
|
+ new Thread(safe).start();
|
|
34
|
+ }
|
27
|
35
|
|
28
|
36
|
// This wait is here because main is still a thread and we want the main method to print the finished copies
|
29
|
37
|
// after enough time has passed.
|
|
@@ -34,5 +42,7 @@ public class MonkeyTypewriter {
|
34
|
42
|
}
|
35
|
43
|
|
36
|
44
|
// Print out the copied versions here.
|
|
45
|
+ System.out.println("Unsafe version: \n" + unsafe.copied);
|
|
46
|
+ System.out.println("Safe version: \n" + safe.copied);
|
37
|
47
|
}
|
38
|
48
|
}
|