author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 33510 | 1895624f2983 |
permissions | -rw-r--r-- |
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
1 |
/* |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
4 |
* |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
8 |
* |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
14 |
* |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
18 |
* |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
21 |
* questions. |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
22 |
*/ |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
23 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
24 |
import java.awt.Frame; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
25 |
import java.awt.GraphicsConfiguration; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
26 |
import java.awt.Window; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
27 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
28 |
import static java.util.concurrent.TimeUnit.MINUTES; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
29 |
import static java.util.concurrent.TimeUnit.NANOSECONDS; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
30 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
31 |
/** |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
32 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
33510
diff
changeset
|
33 |
* @key headful |
33510
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
34 |
* @bug 8138764 |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
35 |
*/ |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
36 |
public final class TreeLockDeadlock extends Frame { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
37 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
38 |
@Override |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
39 |
public synchronized GraphicsConfiguration getGraphicsConfiguration() { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
40 |
return super.getGraphicsConfiguration(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
41 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
42 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
43 |
@Override |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
44 |
public synchronized void reshape(int x, int y, int width, int height) { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
45 |
super.reshape(x, y, width, height); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
46 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
47 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
48 |
@Override |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
49 |
public synchronized float getOpacity() { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
50 |
return super.getOpacity(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
51 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
52 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
53 |
public static void main(final String[] args) throws Exception { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
54 |
final Window window = new TreeLockDeadlock(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
55 |
window.setSize(300, 300); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
56 |
test(window); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
57 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
58 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
59 |
private static void test(final Window window) throws Exception { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
60 |
final long start = System.nanoTime(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
61 |
final long end = start + NANOSECONDS.convert(1, MINUTES); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
62 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
63 |
final Runnable r1 = () -> { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
64 |
while (System.nanoTime() < end) { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
65 |
window.setBounds(window.getBounds()); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
66 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
67 |
}; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
68 |
final Runnable r2 = () -> { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
69 |
while (System.nanoTime() < end) { |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
70 |
window.getGraphicsConfiguration(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
71 |
window.getOpacity(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
72 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
73 |
}; |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
74 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
75 |
final Thread t1 = new Thread(r1); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
76 |
final Thread t2 = new Thread(r1); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
77 |
final Thread t3 = new Thread(r2); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
78 |
final Thread t4 = new Thread(r2); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
79 |
|
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
80 |
t1.start(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
81 |
t2.start(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
82 |
t3.start(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
83 |
t4.start(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
84 |
t1.join(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
85 |
t2.join(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
86 |
t3.join(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
87 |
t4.join(); |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
88 |
} |
1895624f2983
8138764: In some cases the usage of TreeLock can be replaced by other synchronization
serb
parents:
diff
changeset
|
89 |
} |