Mercurial > hg > truffle
annotate test/compiler/6863420/Test.java @ 6076:b4f7c4315c36
Merge
author | zgu |
---|---|
date | Sat, 12 May 2012 06:50:41 -0400 |
parents | c18cbe5936b8 |
children | f67065f02409 |
rev | line source |
---|---|
894 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
894
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
894
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
894
diff
changeset
|
21 * questions. |
894 | 22 * |
23 */ | |
24 | |
25 /** | |
26 * @test | |
27 * @bug 6863420 | |
28 * @summary os::javaTimeNanos() go backward on Solaris x86 | |
29 * | |
30 * @run main/othervm Test | |
31 */ | |
32 | |
33 public class Test { | |
34 static long value = 0; | |
35 static boolean got_backward_time = false; | |
36 | |
37 public static void main(String args[]) { | |
38 final int count = 100000; | |
39 | |
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; | |
44 | |
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 } | |
86 | |
87 if (got_backward_time) { | |
88 System.exit(97); | |
89 } | |
90 } | |
91 } |