ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Random/DistinctSeeds.java
Revision: 1.6
Committed: Mon Aug 31 22:24:46 2009 UTC (14 years, 8 months ago) by jsr166
Branch: MAIN
Changes since 1.5: +4 -4 lines
Log Message:
untabify

File Contents

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