forked from teddyzhang1976/ThinkInJava4thSampleCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvenGenerator.java
More file actions
19 lines (18 loc) · 500 Bytes
/
EvenGenerator.java
File metadata and controls
19 lines (18 loc) · 500 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//: concurrency/EvenGenerator.java
package concurrency; /* Added by Eclipse.py */
// When threads collide.
public class EvenGenerator extends IntGenerator {
private int currentEvenValue = 0;
public int next() {
++currentEvenValue; // Danger point here!
++currentEvenValue;
return currentEvenValue;
}
public static void main(String[] args) {
EvenChecker.test(new EvenGenerator());
}
} /* Output: (Sample)
Press Control-C to exit
89476993 not even!
89476993 not even!
*///:~