Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/EventQueue/PushPopDeadlock2/PushPopTest.java
41153 views
1
/*
2
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. 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
24
/*
25
@test
26
@key headful
27
@bug 4913324
28
@author Oleg Sukhodolsky: area=eventqueue
29
@modules java.desktop/sun.awt
30
@run main/timeout=30 PushPopTest
31
*/
32
33
import java.awt.*;
34
import java.awt.event.*;
35
import java.util.EmptyStackException;
36
import sun.awt.SunToolkit;
37
38
public class PushPopTest {
39
40
public static Frame frame;
41
public static void main(String[] args) {
42
frame = new Frame("");
43
frame.pack();
44
45
Runnable dummy = new Runnable() {
46
public void run() {
47
System.err.println("Dummy is here.");
48
System.err.flush();
49
}
50
};
51
EventQueue seq = Toolkit.getDefaultToolkit().getSystemEventQueue();
52
MyEventQueue1 eq1 = new MyEventQueue1();
53
MyEventQueue2 eq2 = new MyEventQueue2();
54
EventQueue.invokeLater(dummy);
55
56
seq.push(eq1);
57
EventQueue.invokeLater(dummy);
58
59
eq1.push(eq2);
60
EventQueue.invokeLater(dummy);
61
Runnable runnable = new Runnable() {
62
public void run() {
63
System.err.println("Dummy from SunToolkit");
64
System.err.flush();
65
}
66
};
67
InvocationEvent ie = new InvocationEvent(eq2, runnable, null, false);
68
// System.err.println(ie);
69
SunToolkit.postEvent(SunToolkit.targetToAppContext(frame), ie);
70
eq1.pop();
71
frame.dispose();
72
}
73
}
74
75
class MyEventQueue1 extends EventQueue {
76
77
public void pop() {
78
super.pop();
79
}
80
}
81
82
class MyEventQueue2 extends EventQueue {
83
84
protected void pop() {
85
System.err.println("pop2()");
86
Thread.dumpStack();
87
try {
88
EventQueue.invokeAndWait(new Runnable() {
89
public void run() {
90
Runnable runnable = new Runnable() {
91
public void run() {
92
System.err.println("Dummy from pop");
93
System.err.flush();
94
}
95
};
96
InvocationEvent ie = new InvocationEvent(MyEventQueue2.this, runnable, null, false);
97
SunToolkit.postEvent(SunToolkit.targetToAppContext(PushPopTest.frame), ie);
98
postEvent(ie);
99
}
100
});
101
} catch (InterruptedException ie) {
102
ie.printStackTrace();
103
} catch (java.lang.reflect.InvocationTargetException ie) {
104
ie.printStackTrace();
105
}
106
super.pop();
107
}
108
}
109
110