1 |
jsr166 |
1.1 |
/** |
2 |
jsr166 |
1.2 |
* @test %I% %E% |
3 |
jsr166 |
1.1 |
* @bug 4949279 |
4 |
|
|
* @summary Independent instantiations of Random() have distinct seeds. |
5 |
|
|
*/ |
6 |
|
|
|
7 |
dl |
1.3 |
/* |
8 |
|
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
9 |
|
|
* Expert Group and released to the public domain, as explained at |
10 |
|
|
* http://creativecommons.org/licenses/publicdomain |
11 |
|
|
*/ |
12 |
|
|
|
13 |
|
|
|
14 |
jsr166 |
1.1 |
import java.util.Random; |
15 |
|
|
|
16 |
|
|
public class DistinctSeeds { |
17 |
|
|
public static void main(String[] args) throws Exception { |
18 |
jsr166 |
1.2 |
// Strictly speaking, it is possible for these to randomly fail, |
19 |
|
|
// but the probability should be *extremely* small (< 2**-63). |
20 |
|
|
if (new Random().nextLong() == new Random().nextLong() || |
21 |
|
|
new Random().nextLong() == new Random().nextLong()) |
22 |
|
|
throw new RuntimeException("Random() seeds not unique."); |
23 |
jsr166 |
1.1 |
} |
24 |
|
|
} |