test/compiler/6863420/Test.java

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1329
665be97e8704
child 4907
f67065f02409
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

     1 /*
     2  * Copyright 2009 D.E. Shaw.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 /**
    26  * @test
    27  * @bug 6863420
    28  * @summary os::javaTimeNanos() go backward on Solaris x86
    29  *
    30  * @run main/othervm Test
    31  */
    33 public class Test {
    34     static long value = 0;
    35     static boolean got_backward_time = false;
    37     public static void main(String args[]) {
    38         final int count = 100000;
    40         for (int numThreads = 1; numThreads <= 32; numThreads++) {
    41             final int numRuns = 1;
    42             for (int t=1; t <= numRuns; t++) {
    43                 final int curRun = t;
    45                 System.out.println("Spawning " + numThreads + " threads");
    46                 final Thread threads[] = new Thread[numThreads];
    47                 for (int i = 0; i < threads.length; i++) {
    48                     Runnable thread =
    49                         new Runnable() {
    50                             public void run() {
    51                                 for (long l = 0; l < 100000; l++) {
    52                                     final long start = System.nanoTime();
    53                                     if (value == 12345678) {
    54                                         System.out.println("Wow!");
    55                                     }
    56                                     final long end = System.nanoTime();
    57                                     final long time = end - start;
    58                                     value += time;
    59                                     if (time < 0) {
    60                                         System.out.println(
    61                                             "Backwards: " +
    62                                             "start=" + start + " " +
    63                                             "end=" + end + " " +
    64                                             "time= " + time
    65                                         );
    66                                         got_backward_time = true;
    67                                     }
    68                                 }
    69                             }
    70                         };
    71                     threads[i] = new Thread(thread, "Thread" + i);
    72                 }
    73                 for (int i = 0; i < threads.length; i++) {
    74                     threads[i].start();
    75                 }
    76                 for (int i = 0; i < threads.length; i++) {
    77                     try {
    78                         threads[i].join();
    79                     }
    80                     catch (InterruptedException e) {
    81                         continue;
    82                     }
    83                 }
    84             }
    85         }
    87         if (got_backward_time) {
    88             System.exit(97);
    89         }
    90     }
    91 }

mercurial