|
@@ -0,0 +1,38 @@
|
|
1
|
+package io.zipcoder;
|
|
2
|
+
|
|
3
|
+public class MonkeyTypewriter {
|
|
4
|
+ public static void main(String[] args) {
|
|
5
|
+ String introduction = "It was the best of times,\n" +
|
|
6
|
+ "it was the blurst of times,\n" +
|
|
7
|
+ "it was the age of wisdom,\n" +
|
|
8
|
+ "it was the age of foolishness,\n" +
|
|
9
|
+ "it was the epoch of belief,\n" +
|
|
10
|
+ "it was the epoch of incredulity,\n" +
|
|
11
|
+ "it was the season of Light,\n" +
|
|
12
|
+ "it was the season of Darkness,\n" +
|
|
13
|
+ "it was the spring of hope,\n" +
|
|
14
|
+ "it was the winter of despair,\n" +
|
|
15
|
+ "we had everything before us,\n" +
|
|
16
|
+ "we had nothing before us,\n" +
|
|
17
|
+ "we were all going direct to Heaven,\n" +
|
|
18
|
+ "we were all going direct the other way--\n" +
|
|
19
|
+ "in short, the period was so far like the present period, that some of\n" +
|
|
20
|
+ "its noisiest authorities insisted on its being received, for good or for\n" +
|
|
21
|
+ "evil, in the superlative degree of comparison only.";
|
|
22
|
+
|
|
23
|
+ // Do all of the Monkey / Thread building here
|
|
24
|
+ // For each Copier(one safe and one unsafe), create and start 5 monkeys copying the introduction to
|
|
25
|
+ // A Tale Of Two Cities.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+ // This wait is here because main is still a thread and we want the main method to print the finished copies
|
|
29
|
+ // after enough time has passed.
|
|
30
|
+ try {
|
|
31
|
+ Thread.sleep(1000);
|
|
32
|
+ } catch(InterruptedException e) {
|
|
33
|
+ System.out.println("MAIN INTERRUPTED");
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ // Print out the copied versions here.
|
|
37
|
+ }
|
|
38
|
+}
|