forked from hansiming/JavaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvenGenerator.java
More file actions
28 lines (21 loc) · 539 Bytes
/
EvenGenerator.java
File metadata and controls
28 lines (21 loc) · 539 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.csdhsm.concurrent;
/**
* @Title: EvenGenerator.java
* @Package: com.csdhsm.concurrent
* @Description synchronized 关键字
* @author Han
* @date 2016-4-9 下午8:58:42
* @version V1.0
*/
public class EvenGenerator extends IntGenerator{
private int currentEvenValue = 0;
@Override
public synchronized int next() {
++currentEvenValue;//danger point in here
++currentEvenValue;
return currentEvenValue;
}
public static void main(String[] args) {
EvenChecker.test(new EvenGenerator());
}
}