forked from ReactiveDesignPatterns/CodeSamples
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathIntSeeding.java
More file actions
35 lines (29 loc) · 740 Bytes
/
IntSeeding.java
File metadata and controls
35 lines (29 loc) · 740 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
29
30
31
32
33
34
35
/*
* Copyright (c) 2018 https://www.reactivedesignpatterns.com/
*
* Copyright (c) 2018 https://rdp.reactiveplatform.xyz/
*
*/
package chapter03;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ThreadLocalRandom;
// 代码清单3-7
public class IntSeeding {
private static final Logger logger = LoggerFactory.getLogger(IntSeeding.class);
public class IntRandom {
public int next() {
return ThreadLocalRandom.current().nextInt();
}
}
private final IntRandom se = new IntRandom();
public int nextInt() {
// #snip
final int next = se.next();
if (logger.isDebugEnabled()) {
logger.debug("Next is " + se.next());
}
return next;
// #snip
}
}