|
@@ -1,5 +1,7 @@
|
1
|
1
|
package io.zipcoder;
|
2
|
2
|
|
|
3
|
+import java.util.ArrayList;
|
|
4
|
+
|
3
|
5
|
public class MonkeyTypewriter {
|
4
|
6
|
public static void main(String[] args) {
|
5
|
7
|
String introduction = "It was the best of times,\n" +
|
|
@@ -38,6 +40,8 @@ public class MonkeyTypewriter {
|
38
|
40
|
monkey5.start();
|
39
|
41
|
|
40
|
42
|
SafeCopier safeCopier = new SafeCopier(introduction);
|
|
43
|
+
|
|
44
|
+ ArrayList<Thread>monkeys = new ArrayList<Thread>();
|
41
|
45
|
Thread monkeySafe1 = new Thread(safeCopier);
|
42
|
46
|
Thread monkeySafe2 = new Thread(safeCopier);
|
43
|
47
|
Thread monkeySafe3 = new Thread(safeCopier);
|
|
@@ -51,6 +55,7 @@ public class MonkeyTypewriter {
|
51
|
55
|
monkeySafe5.start();
|
52
|
56
|
|
53
|
57
|
|
|
58
|
+
|
54
|
59
|
// This wait is here because main is still a thread and we want the main method to print the finished copies
|
55
|
60
|
// after enough time has passed.
|
56
|
61
|
try {
|
|
@@ -64,5 +69,6 @@ public class MonkeyTypewriter {
|
64
|
69
|
System.out.println(unsafeCopier.copied);
|
65
|
70
|
System.out.println("----------Safe----------");
|
66
|
71
|
System.out.println(safeCopier.copied);
|
|
72
|
+
|
67
|
73
|
}
|
68
|
74
|
}
|