Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001.java
40948 views
1
/*
2
* Copyright (c) 2003, 2018, 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
package nsk.jvmti.GetAllThreads;
25
26
import java.io.PrintStream;
27
28
public class allthr001 {
29
30
static {
31
try {
32
System.loadLibrary("allthr001");
33
} catch (UnsatisfiedLinkError ule) {
34
System.err.println("Could not load allthr001 library");
35
System.err.println("java.library.path:"
36
+ System.getProperty("java.library.path"));
37
throw ule;
38
}
39
}
40
41
native static void setSysCnt();
42
native static void checkInfo(int thr_ind);
43
native static int getRes();
44
45
public static Object lock1 = new Object();
46
public static Object lock2 = new Object();
47
public static int waitTime = 2;
48
49
public static void main(String[] args) {
50
args = nsk.share.jvmti.JVMTITest.commonInit(args);
51
52
System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
53
}
54
55
public static int run(String args[], PrintStream out) {
56
if (args.length > 0) {
57
try {
58
int i = Integer.parseInt(args[0]);
59
waitTime = i;
60
} catch (NumberFormatException ex) {
61
out.println("# Wrong argument \"" + args[0]
62
+ "\", the default value is used");
63
}
64
}
65
out.println("# Waiting time = " + waitTime + " mins");
66
67
setSysCnt();
68
checkInfo(0);
69
70
ThreadGroup tg = new ThreadGroup("tg1");
71
allthr001a t_a = new allthr001a(tg, "thread1");
72
t_a.setDaemon(true);
73
checkInfo(1);
74
75
synchronized (lock1) {
76
try {
77
t_a.start();
78
lock1.wait();
79
} catch (InterruptedException e) {
80
throw new Error("Unexpected " + e);
81
}
82
}
83
checkInfo(2);
84
85
synchronized (lock2) {
86
lock2.notify();
87
}
88
89
try {
90
t_a.join(waitTime * 60000);
91
} catch (InterruptedException e) {
92
throw new Error("Unexpected " + e);
93
}
94
checkInfo(3);
95
96
checkInfo(4);
97
return getRes();
98
}
99
}
100
101
class allthr001a extends Thread {
102
allthr001a(ThreadGroup tg, String name) {
103
super(tg, name);
104
}
105
106
public void run() {
107
synchronized (allthr001.lock2) {
108
synchronized (allthr001.lock1) {
109
allthr001.lock1.notify();
110
}
111
try {
112
allthr001.lock2.wait();
113
} catch (InterruptedException e) {
114
throw new Error("Unexpected " + e);
115
}
116
}
117
}
118
}
119
120