Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/gctest03/appthread.java
41155 views
1
/*
2
* Copyright (c) 2002, 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 gc.gctests.gctest03;
25
26
import nsk.share.test.*;
27
import nsk.share.gc.*;
28
29
//import Tree;
30
//import LocalRandom;
31
32
// remove the nodes whose key is the multiple of key from the tree
33
class Redthread extends Thread {
34
Tree optree;
35
int key;
36
37
Redthread(Tree tr, int k)
38
{
39
optree = tr;
40
key = k;
41
}
42
43
public void run() {
44
int maxsz = (1024 * 64); // 64k
45
int i = 1;
46
int sz;
47
48
sz = 1;
49
50
while ( optree.isempty() == false)
51
{
52
DataNode d;
53
// System.out.println(getName() + i);
54
// sz = (key * i) % maxsz;
55
try
56
{
57
d = new DataNode(sz);
58
}
59
catch (DataNodeException e)
60
{
61
//System.out.println(getName() + " exiting");
62
return;
63
}
64
if (optree.remove(d))
65
// System.out.println(getName() + " removes " + sz);
66
i++;
67
try
68
{
69
sleep(3);
70
}
71
catch(InterruptedException e) {}
72
73
// optree.sort1();
74
sz++;
75
}
76
}
77
}
78
79
// add the nodes whose key is the multiple of key from the tree
80
class Bluethread extends Thread {
81
Tree optree;
82
int key;
83
private int loopcount = 0;
84
85
Bluethread(Tree tr, int k)
86
{
87
optree = tr;
88
key = k;
89
}
90
91
public void setloop(int n)
92
{
93
loopcount = n;
94
}
95
96
public void run()
97
{
98
int i;
99
int sz;
100
int maxsz = (1024 * 64); // 64k
101
102
i = 1; sz = 0;
103
while ( (loopcount== 0) ? true : (i < loopcount) )
104
{
105
sz = (key * i) % maxsz;
106
DataNode d;
107
108
try
109
{
110
d= new DataNode(sz);
111
}
112
catch (DataNodeException e)
113
{
114
//System.out.println(getName() + " exiting");
115
return;
116
}
117
118
TreeNode t = new TreeNode(d);
119
// System.out.println(getName() + i);
120
if ( optree.search(d) == null )
121
{
122
optree.insert(t);
123
// System.out.println(getName() + " insert " + sz);
124
}
125
//optree.sort1();
126
i++;
127
try
128
{
129
sleep(5);
130
}
131
catch(InterruptedException e) {}
132
}
133
}
134
}
135
136
class Yellowthread extends Thread {
137
Tree optree;
138
int key; // data to be moved from the tree
139
140
Yellowthread(Tree tr, int k)
141
{
142
optree = tr;
143
key = k;
144
}
145
146
// remove the nodes whose key is the multiple of key from the tree
147
public void run()
148
{
149
int i = 1;
150
while ( true )
151
{
152
DataNode d;
153
try
154
{
155
d = new DataNode(key*i);
156
}
157
catch (DataNodeException e)
158
{
159
//System.out.println(getName() + " exiting");
160
return;
161
}
162
TreeNode t = optree.search(d);
163
/* if ( t != null ) System.out.println(getName() + ": search = " +
164
* (t.getData()).getkey());
165
*/
166
i++;
167
if ( LocalRandom.random() < 0.668 )
168
{
169
try
170
{
171
sleep(5);
172
}
173
catch(InterruptedException e) {}
174
}
175
}
176
}
177
}
178
179
public class appthread {
180
}
181
182