ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Random/DistinctSeeds.java
Revision: 1.1
Committed: Fri Nov 7 01:35:36 2003 UTC (20 years, 6 months ago) by jsr166
Branch: MAIN
Log Message:
4949279: no-arg Random constructor should use nanoTime for seed.

File Contents

# User Rev Content
1 jsr166 1.1 /**
2     * @test 1.1 03/11/06
3     * @bug 4949279
4     * @summary Independent instantiations of Random() have distinct seeds.
5     */
6    
7     import java.util.Random;
8    
9     public class DistinctSeeds {
10     public static void main(String[] args) throws Exception {
11     // Strictly speaking, it is possible for these to be equal,
12     // but the likelihood should be *extremely* small.
13     if (new Random().nextLong() == new Random().nextLong())
14     throw new RuntimeException("Random seeds not unique.");
15     }
16     }