author | darcy |
Wed, 18 Jan 2012 16:43:59 -0800 | |
changeset 11553 | 4389b722f8dc |
parent 5547 | f4b087cbb361 |
child 16688 | c5d0a0a90f37 |
permissions | -rw-r--r-- |
3594 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3594
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3594
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3594
diff
changeset
|
21 |
* questions. |
3594 | 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 |
} |