|
@@ -10,5 +10,27 @@ public class UnsafeCopier extends Copier {
|
10
|
10
|
}
|
11
|
11
|
|
12
|
12
|
public void run() {
|
|
13
|
+ while ( stringIterator.hasNext()) { // stringIterator comes from Copier
|
|
14
|
+ copied += stringIterator.next() + " ";
|
|
15
|
+ }
|
13
|
16
|
}
|
14
|
17
|
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+/*
|
|
21
|
+Part 1
|
|
22
|
+
|
|
23
|
+Made for you is an abstract base class of Copier which has a constructor that takes a String and turns that into an iterator.
|
|
24
|
+This will allow us to traverse the text to be copied and pass it along to each monkey (thread).
|
|
25
|
+
|
|
26
|
+Extend Copier in UnsafeCopier.
|
|
27
|
+Then, write a run method that will have the monkey grab the next word and append it to the copy.
|
|
28
|
+
|
|
29
|
+Modify MonkeyTypewriter to create 5 monkeys (threads) using the UnsafeCopier and start them.
|
|
30
|
+
|
|
31
|
+After the sleep, print out the results of the unsafely copied passage.
|
|
32
|
+
|
|
33
|
+Part 2
|
|
34
|
+
|
|
35
|
+Finish the SafeCopier and then call that from the main method, in addition to the unsafe version.
|
|
36
|
+ */
|