1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.hipparchus.random;
23
24
25
26
27
28
29
30
31 public class SynchronizedRandomGenerator implements RandomGenerator {
32
33
34 private final RandomGenerator wrapped;
35
36
37
38
39
40
41
42
43
44
45 public SynchronizedRandomGenerator(RandomGenerator rng) {
46 wrapped = rng;
47 }
48
49
50 @Override
51 public void setSeed(int seed) {
52 synchronized (wrapped) {
53 wrapped.setSeed(seed);
54 }
55 }
56
57
58 @Override
59 public void setSeed(int[] seed) {
60 synchronized (wrapped) {
61 wrapped.setSeed(seed);
62 }
63 }
64
65
66 @Override
67 public void setSeed(long seed) {
68 synchronized (wrapped) {
69 wrapped.setSeed(seed);
70 }
71 }
72
73
74 @Override
75 public void nextBytes(byte[] bytes) {
76 synchronized (wrapped) {
77 wrapped.nextBytes(bytes);
78 }
79 }
80
81
82 @Override
83 public void nextBytes(byte[] bytes, int offset, int len) {
84 synchronized (wrapped) {
85 wrapped.nextBytes(bytes, offset, len);
86 }
87 }
88
89
90 @Override
91 public int nextInt() {
92 synchronized (wrapped) {
93 return wrapped.nextInt();
94 }
95 }
96
97
98 @Override
99 public int nextInt(int n) {
100 synchronized (wrapped) {
101 return wrapped.nextInt(n);
102 }
103 }
104
105
106 @Override
107 public long nextLong() {
108 synchronized (wrapped) {
109 return wrapped.nextLong();
110 }
111 }
112
113
114 @Override
115 public long nextLong(long n) {
116 synchronized (wrapped) {
117 return wrapped.nextLong(n);
118 }
119 }
120
121
122 @Override
123 public boolean nextBoolean() {
124 synchronized (wrapped) {
125 return wrapped.nextBoolean();
126 }
127 }
128
129
130 @Override
131 public float nextFloat() {
132 synchronized (wrapped) {
133 return wrapped.nextFloat();
134 }
135 }
136
137
138 @Override
139 public double nextDouble() {
140 synchronized (wrapped) {
141 return wrapped.nextDouble();
142 }
143 }
144
145
146 @Override
147 public double nextGaussian() {
148 synchronized (wrapped) {
149 return wrapped.nextGaussian();
150 }
151 }
152
153 }